Hi!
For some reason, my dll entryPoint doesn't enter to "DLL_THREAD_DETACH"
and because of that i cant close the threads i opened.
i am using these functions (taken from a class):
i cant get to the "_monitor.endThread()" function.Code:void myThread::startThread() { this->stopFlag = CreateEvent(NULL,false,false,L"myEvent"); CreateThread(NULL,NULL,&myThread::threadProc,this,0,NULL); } void myThread::endThread() { SetEvent(this->stopFlag); CloseHandle(this->stopFlag); CloseHandle(this->threadHandle); } void myThread::startMonitor() { while(true) { Sleep(2000); if (WAIT_OBJECT_0 == WaitForSingleObject(this->stopFlag,0)) break; } } DWORD WINAPI myThread::threadProc(LPVOID param) { myThread* tmp = (myThread*)param; tmp->startMonitor(); return 0; } and the entryPoint: myThread _monitor; BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: _monitor.startThread(); break; case DLL_THREAD_DETACH: _monitor.endThread(); break; case DLL_PROCESS_DETACH: break; } return TRUE; }
tnx for the help and sorry for the lame english.




Reply With Quote