额...解决办法貌似很简单,,,,只需把线程过程声明为静态就行了 static
#include <windows.h> #include <IOSTREAM> struct myStruct{ int a; char b; }; class MyTestClass{ public: BOOL MycreateThread(){ myStruct *pStruct=new myStruct; pStruct->a=123; pStruct->b='f'; m_hThread=CreateThread(NULL,0,MyThreadProc,(LPVOID)pStruct,0,NULL); return m_hThread?TRUE:FALSE; }; HANDLE getThreadHandle(){return m_hThread;} static DWORD WINAPI MyThreadProc(LPVOID lpParamete){ myStruct *pStruct=((myStruct*)lpParamete); std::cout<<"Thread is Running...."<<std::endl <<"a="<<pStruct->a<<"\t b="<<pStruct->b<<std::endl; return 0; } ~MyTestClass(){CloseHandle(m_hThread);} private: HANDLE m_hThread; }; int main() { MyTestClass myTestClass; myTestClass.MycreateThread(); WaitForSingleObject(myTestClass.getThreadHandle(),INFINITE); return 0; }