//如何把下面的C++代码转换成C#代码?BOOL CALLBACK lpEnumFunc3(HWND hwnd, LPARAM lParam)
{
LPTSTR strClassName;
CString s;
CString tmpStr;
//根据句柄获取类名
strClassName=s.GetBuffer(255);
::GetClassName(hwnd,strClassName,255);
tmpStr = (CString)strClassName;
tmpStr.TrimLeft();
tmpStr.TrimRight();
s.ReleaseBuffer();
if (tmpStr == "ComboBoxEx32")
{
//获取存储文件路径的文本框的句柄
HWND temp1 = FindWindowEx(hwnd,NULL,"ComboBox",NULL);
hWavPath= FindWindowEx(temp1,NULL,"Edit",NULL);
}
return TRUE;
}
//线程功能函数
BOOL CVoiceManager::ReceivingLoop(void)
{
CString curPath = myDB.GetModuleDir(); //应用程序当前路径
CString loTmpPath = curPath + "\\tmpFile\\";
CString loAudioPaht = curPath + "\\audioFile\\";
gAudioFile = loAudioPaht;
CString tmpUserId;
CString tmpSendId;
memset(&strTTS,0,sizeof(strTTS));
//获取TTS程序窗体上文本框和保存按纽的句柄
EnumWindows(lpEnumFunc,NULL);
while(bFlag) //循环查询,转换音频文件
{
myDB.mySQLQuery(&strTTS);
for (int iCount = 0; iCount < 100;iCount++)
{
if (strTTS.sendid[iCount][0] !='\0') //为空的时候不执行if??????
{
//向TTS程序文本框中填写数据
if (hTTSAppEdit != NULL)
{
//获取要转换的内容
::SendMessage(hTTSAppEdit,WM_SETTEXT,0,LPARAM(strTTS.content[iCount]));
}
else
{
//AfxMessageBox("没找到TTS文本框");
}
if (hTTSAppForm != NULL)
{
//向TTS程序的"保存"按纽发送鼠标单击消息
::PostMessage(hTTSAppForm,WM_COMMAND,(WPARAM)CONTROL_ID_VOICE_SAVE, LPARAM(NULL)) ;
//获取另存为窗体的句柄===============
Sleep(500);
EnumWindows(lpEnumFunc2,NULL);
//获取另存为窗体下的"路径"文本框和"保存"按纽的句柄
EnumChildWindows(hSaveForm,lpEnumFunc3,NULL);
if (hSaveForm == NULL)
{
//AfxMessageBox("没找到 另存为窗体");
}
if ( hWavPath != NULL)
{
//拼接文件名
SYSTEMTIME t;
GetLocalTime(&t);
CString strTmp;
strTmp.Format("%d%d%d%d%d%d%d",t.wYear,t.wMonth,t.wDay,t.wHour,t.wMinute,t.wSecond,t.wMilliseconds);
CString str;
str =strTTS.username[iCount];
str += strTmp;
str = loTmpPath +str;
//获取文件路径名
LPTSTR a= (LPTSTR)LPCTSTR(str);
::SendMessage(hWavPath,WM_SETTEXT,0,LPARAM(a));
Sleep(100);
}
else
{
//AfxMessageBox("没找到路径文本框");
}
if (hSaveForm != NULL)
{
//向"另存为"窗体的保存按纽发送鼠标单击事件
::PostMessage(hSaveForm,WM_COMMAND,(WPARAM)CONTROL_ID_VOICE_SAVE2, LPARAM(NULL)) ;
EnumWindows(lpEnumFunc4,NULL);
if (hOKForm != NULL)
{
//AfxMessageBox("找到确认按纽");
::PostMessage(hOKForm,WM_COMMAND,(WPARAM)CONTROL_ID_VOICE_OK, LPARAM(NULL)) ;
//更新数据库
tmpUserId = strTTS.username[iCount];
tmpSendId = strTTS.sendid[iCount];
myDB.updateSFlg(tmpUserId,tmpSendId);
}
else
{
Sleep(2000);
EnumWindows(lpEnumFunc4,NULL);
::PostMessage(hOKForm,WM_COMMAND,(WPARAM)CONTROL_ID_VOICE_OK, LPARAM(NULL)) ;
//更新数据库
tmpUserId = strTTS.username[iCount];
tmpSendId = strTTS.sendid[iCount];
myDB.updateSFlg(tmpUserId,tmpSendId);
}
}
} // if (hTTSAppForm != NULL)
} //if (strTTS.sendid[iCount] !="")
} //for (int iCount = 0; iCount < 100;iCount++)
//一批转换结束之后,上传到ftp上
memset(&strTTS,0,sizeof(strTTS));
//upFile(loTmpPath,"\\\\callcenter\\"); //上传到Windows服务器
upFileTest(loTmpPath,"//callcenter/"); //上传到Linux服务器
//把生成的临时音频文件删除掉
char *p;
p = loTmpPath.GetBuffer(loTmpPath.GetLength());
delfolderallfies(p);
//AfxMessageBox("本批音频处理结束");
Sleep(5);
} return TRUE;
}
{
LPTSTR strClassName;
CString s;
CString tmpStr;
//根据句柄获取类名
strClassName=s.GetBuffer(255);
::GetClassName(hwnd,strClassName,255);
tmpStr = (CString)strClassName;
tmpStr.TrimLeft();
tmpStr.TrimRight();
s.ReleaseBuffer();
if (tmpStr == "ComboBoxEx32")
{
//获取存储文件路径的文本框的句柄
HWND temp1 = FindWindowEx(hwnd,NULL,"ComboBox",NULL);
hWavPath= FindWindowEx(temp1,NULL,"Edit",NULL);
}
return TRUE;
}
//线程功能函数
BOOL CVoiceManager::ReceivingLoop(void)
{
CString curPath = myDB.GetModuleDir(); //应用程序当前路径
CString loTmpPath = curPath + "\\tmpFile\\";
CString loAudioPaht = curPath + "\\audioFile\\";
gAudioFile = loAudioPaht;
CString tmpUserId;
CString tmpSendId;
memset(&strTTS,0,sizeof(strTTS));
//获取TTS程序窗体上文本框和保存按纽的句柄
EnumWindows(lpEnumFunc,NULL);
while(bFlag) //循环查询,转换音频文件
{
myDB.mySQLQuery(&strTTS);
for (int iCount = 0; iCount < 100;iCount++)
{
if (strTTS.sendid[iCount][0] !='\0') //为空的时候不执行if??????
{
//向TTS程序文本框中填写数据
if (hTTSAppEdit != NULL)
{
//获取要转换的内容
::SendMessage(hTTSAppEdit,WM_SETTEXT,0,LPARAM(strTTS.content[iCount]));
}
else
{
//AfxMessageBox("没找到TTS文本框");
}
if (hTTSAppForm != NULL)
{
//向TTS程序的"保存"按纽发送鼠标单击消息
::PostMessage(hTTSAppForm,WM_COMMAND,(WPARAM)CONTROL_ID_VOICE_SAVE, LPARAM(NULL)) ;
//获取另存为窗体的句柄===============
Sleep(500);
EnumWindows(lpEnumFunc2,NULL);
//获取另存为窗体下的"路径"文本框和"保存"按纽的句柄
EnumChildWindows(hSaveForm,lpEnumFunc3,NULL);
if (hSaveForm == NULL)
{
//AfxMessageBox("没找到 另存为窗体");
}
if ( hWavPath != NULL)
{
//拼接文件名
SYSTEMTIME t;
GetLocalTime(&t);
CString strTmp;
strTmp.Format("%d%d%d%d%d%d%d",t.wYear,t.wMonth,t.wDay,t.wHour,t.wMinute,t.wSecond,t.wMilliseconds);
CString str;
str =strTTS.username[iCount];
str += strTmp;
str = loTmpPath +str;
//获取文件路径名
LPTSTR a= (LPTSTR)LPCTSTR(str);
::SendMessage(hWavPath,WM_SETTEXT,0,LPARAM(a));
Sleep(100);
}
else
{
//AfxMessageBox("没找到路径文本框");
}
if (hSaveForm != NULL)
{
//向"另存为"窗体的保存按纽发送鼠标单击事件
::PostMessage(hSaveForm,WM_COMMAND,(WPARAM)CONTROL_ID_VOICE_SAVE2, LPARAM(NULL)) ;
EnumWindows(lpEnumFunc4,NULL);
if (hOKForm != NULL)
{
//AfxMessageBox("找到确认按纽");
::PostMessage(hOKForm,WM_COMMAND,(WPARAM)CONTROL_ID_VOICE_OK, LPARAM(NULL)) ;
//更新数据库
tmpUserId = strTTS.username[iCount];
tmpSendId = strTTS.sendid[iCount];
myDB.updateSFlg(tmpUserId,tmpSendId);
}
else
{
Sleep(2000);
EnumWindows(lpEnumFunc4,NULL);
::PostMessage(hOKForm,WM_COMMAND,(WPARAM)CONTROL_ID_VOICE_OK, LPARAM(NULL)) ;
//更新数据库
tmpUserId = strTTS.username[iCount];
tmpSendId = strTTS.sendid[iCount];
myDB.updateSFlg(tmpUserId,tmpSendId);
}
}
} // if (hTTSAppForm != NULL)
} //if (strTTS.sendid[iCount] !="")
} //for (int iCount = 0; iCount < 100;iCount++)
//一批转换结束之后,上传到ftp上
memset(&strTTS,0,sizeof(strTTS));
//upFile(loTmpPath,"\\\\callcenter\\"); //上传到Windows服务器
upFileTest(loTmpPath,"//callcenter/"); //上传到Linux服务器
//把生成的临时音频文件删除掉
char *p;
p = loTmpPath.GetBuffer(loTmpPath.GetLength());
delfolderallfies(p);
//AfxMessageBox("本批音频处理结束");
Sleep(5);
} return TRUE;
}
问题已经解决