有关线程问题 请教下啊 搞好久了
private:DWORD WINAPI GetCom(LPVOID lpParameter);
初始化
BOOL CConfigPort::OnInitDialog()
{
CDialog::OnInitDialog();
HANDLE hThread=CreateThread(NULL, 0, GetCom, NULL, 0, NULL);
CloseHandle(hThread);
}
函数实现
DWORD WINAPI CConfigPort::GetCom(LPVOID lpParameter)
{
HANDLE hCom;
int i,num,k,j;
CString str;
BOOL flag;
const int Comb[3] = {IDC_COMBO1, IDC_COMBO2, IDC_COMBO3};
cnComm *mComAll[3] = {&mCom1, &mCom2, &mCom3};
for(j=0; j<3; j++)
((CComboBox *)GetDlgItem(Comb[j]))->ResetContent(); //init combox0
flag = FALSE;
num = 0;
for(j=0; j<3; j++)
{
for (i = 1;i <= 16;i++)
{//此程序支持16个串口
str.Format("\\\\.\\COM%d",i);
hCom = CreateFile(str, 0, 0, 0,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if(INVALID_HANDLE_VALUE != hCom )
{//能打开该串口,则添加该串口
CloseHandle(hCom);
str = str.Mid(4);
((CComboBox *)GetDlgItem(Comb[j]))->AddString(str);
if (flag == FALSE)
{
flag = TRUE;
num = i;
}
}
}
}
for(j=0; j<3; j++)
{
i = ((CComboBox *)GetDlgItem(Comb[j]))->GetCount();
if (i == 0)
{//若找不到可用串口则禁用“打开串口”功能
((CComboBox *)GetDlgItem(Comb[j]))->EnableWindow(FALSE);
}
else
{
k = ((CComboBox *)GetDlgItem((Comb[j])))->GetCount();
((CComboBox *)GetDlgItem(Comb[j]))->SetCurSel(k - 1);
(*mComAll)++->BindCommPort(num);
//mCom1.BindCommPort(num);
}
}
}
总有错误 error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)(void *)'
按网上的教程 我定义成静态static DWORD WINAPI GetCom(LPVOID lpParameter); 但是问题在于 我函数里有其他的类 CComboBox 不能定义成静态 真心不知道怎么处理 求解答、