静态的线程为什么不能访问类的成员变量??????(有代码)
如题
void CMD5_Dlg2Dlg::OnButton1()
{
CString m_strFilePath;
CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT, "All Files(*.*)|*.*||", this);
if(dlg.DoModal() == IDOK)
{
m_strFilePath = dlg.GetPathName(); //保存发送文件的路径
}
MD5 md5;
CString outHash ;
md5.CreateToThread(m_strFilePath);
md5.GetThreadHashFile();
GetDlgItem(IDC_EDIT1)->SetWindowText(outHash);
}
void MD5::CreateToThread(CString strFilePath)
{
DWORD id;
m_FilePath=strFilePath;
Path=strFilePath;
AfxMessageBox(Path);
HANDLE h = CreateThread(NULL, 0, ThreadHashFile, this, 0, &id);
CloseHandle(h);
}
DWORD WINAPI MD5::ThreadHashFile(LPVOID lpParam)
{
AfxMessageBox(" ThreadHashFile ");
CString tempHash = "";
MD5 * pMD5 = (MD5 *)lpParam;
// MD5 object to work with
MD5_CTX m_md5;
CString outHash;
AfxMessageBox(pMD5->Path); // 这里的Path值和CreateToThread()函数不同
if ( pMD5->Path.IsEmpty() )// 程序运行到这里就报错
return 0;
}