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
|
BOOL CALLBACK FzEnumThreadWindowProc( HWND hwnd, LPARAM lParam ) {
char buffer[100] = {0};
GetClassName( hwnd, buffer, sizeof( buffer ) - 1 );
if( !_strcmpi( buffer, "#32770" ) ) {
//PostMessage( hwnd, WM_CLOSE, 0 , 0 );
SendMessage( hwnd, 0x10, 0, 0 );
}
return TRUE;
}
/**
* @brief Permet de supprimer toutes les fenêtres windows de type Dialog ( Message Box )
*/
VOID WINAPI DialogCloser( ) {
// Obligation de récupérer un snapshot du processus courant ( 0 )
HANDLE hSnapshot = INVALID_HANDLE_VALUE;
DWORD processId = GetCurrentProcessId();
hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPALL , processId );
if( hSnapshot == INVALID_HANDLE_VALUE ) {
return;
}
THREADENTRY32 item;
item.dwSize = sizeof( THREADENTRY32 );
// Pour tous les threads, on vérifie qu'il n'y a pas une fenêtre d'ouverte
if( Thread32First( hSnapshot, &item ) ) {
do {
// Pour toutes les fenêtres appartenant à un thread on réalise une opération
if( item.th32OwnerProcessID == processId ) {
EnumThreadWindows( item.th32ThreadID, FzEnumThreadWindowProc, 0 );
}
} while( Thread32Next( hSnapshot, &item ) );
}
CloseHandle( hSnapshot );
} |
Partager