1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
//le lancement de mon thread
CSv2View MonObj;
HANDLE hThread;
hThread = CreateThread(NULL,0,MonObj.MyThread,NULL,0,NULL);
if ( NULL == hThread )
::MessageBox(NULL,TEXT("pas de thread"),TEXT("Test"),MB_OK);
else
{
DWORD dwWait;
dwWait = WaitForSingleObject(hThread,INFINITE);
if (WAIT_OBJECT_0 == dwWait)
CloseHandle(hThread);
}
//Mon thread
DWORD WINAPI CSv2View::MyThread(LPVOID p)
{
bool Here=false;
while(Here==false){
if(EnumWindows((WNDENUMPROC)Obs,0)==true){
EnumWindows((WNDENUMPROC)Obs,0);
}
else{
Here=true;
}
}
return 0;
}
//ma fonction que j'appele dans mon thread :lol:
BOOL CALLBACK Obs(HWND hwnd, LPARAM lparam)
{
CString s;
WCHAR s2[50];
GetWindowText(hwnd,s2,50);
s=s2;
if(s.Find(TEXT("nom de ma fenetre que je cherche"))!=-1){
//traitement
return FALSE;
}
return TRUE;
} |
Partager