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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| void TFDemarrageInternet::lancerLogiciel()
{
...
STARTUPINFO suInfo;
PROCESS_INFORMATION procInfo;
string m_Process;
memset (&suInfo, 0, sizeof(suInfo));
suInfo.cb = sizeof(suInfo);
m_Process = cheminExecutable+executable;
CreateProcess(m_Process.c_str(),NULL,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&suInfo,&procInfo);
if (procInfo.dwThreadId == NULL)
Application->MessageBoxA("Erreur","nope");
else
this->processPid = procInfo.dwProcessId;
...
}
void TFDemarrageInternet::quitterLogiciel()
{
...
HANDLE ps = OpenProcess( SYNCHRONIZE|PROCESS_TERMINATE,FALSE, this->processPid);
DWORD wndPid;
string Title;
// processPid = procInfo.dwProcessId;
// This function enumerates all widows,
// using the EnumWindowsProc callback
// function, passing the PID of the process
// you started earlier.
EnumWindows(EnumWindowsProc, this->processPid); <<<--- Pb de compilation
CloseHandle(ps) ;
...
}
bool CALLBACK TFDemarrageInternet::EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
DWORD wndPid;
char * Title;
// lParam = procInfo.dwProcessId;
// This gets the windows handle and pid of enumerated window.
GetWindowThreadProcessId(hwnd, &wndPid);
// This gets the windows title text
// from the window, using the window handle
//CWnd::FromHandle(hwnd)->GetWindowText(Title); <<<---ne compile pas sous Builder 6
GetClassName(hwnd,Title,50); <<<---Remplacé par cette ligne là
// this makes sure that the PID matches that PID we started, and window
// text exists, before we kill it . I don't think this is really needed,
// I included it because some apps have more than one window.
if ( wndPid == (DWORD)lParam && sizeof(Title) != 0)
{
// Please kindly close this process
::PostMessage(hwnd, WM_CLOSE, 0, 0);
return false;
}
else
{
// Keep enumerating
return true;
}
} |
Partager