+ -
当前位置:首页 → 问答吧 → 新开线程问题

新开线程问题

时间:2011-12-13

来源:互联网

源代码
void CFileServerManagerDlg::OnBnClickedButton()
{
// TODO: Add your control notification handler code here
CString strPath;
strPath.Format(_T("d:\\"));
CWinThread * pThread1;
pThread1=AfxBeginThread(&CFileServerManagerDlg::GetFileAttributesThread,&strPath,THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
pThread1->ResumeThread();
}
出错信息:
error C2665: 'AfxBeginThread' : none of the 2 overloads could convert all the argument types
1> d:\program files (x86)\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(4535): could be 'CWinThread *AfxBeginThread(AFX_THREADPROC,LPVOID,int,UINT,DWORD,LPSECURITY_ATTRIBUTES)'
1> d:\program files (x86)\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(4538): or 'CWinThread *AfxBeginThread(CRuntimeClass *,int,UINT,DWORD,LPSECURITY_ATTRIBUTES)'
1> while trying to match the argument list '(UINT (__thiscall CFileServerManagerDlg::* )(LPVOID), CString *, int, int, int)'

作者: wmjhl   发布时间: 2011-12-13

错误不都写了吗,afxbeginthread的用法不对,怀疑是现成函数的定义不对

作者: mayudong1   发布时间: 2011-12-13

CFileServerManagerDlg::GetFileAttributesThread应为静态,参数也不对

改成
class CFileServerManagerDlg
{
...
static UINT GetFileAttributesThread(LPVOID pParam);
...
}

另外不要传局部变量(CString strPath;)到线程里

作者: stjay   发布时间: 2011-12-13

GetFileAttributesThread函数怎么申明的,参数是什么,都要符合AfxBeginThread的要求啊,不能乱来

作者: yayafu   发布时间: 2011-12-13

热门下载

更多