Caption:
[php]
DWORD GetProcessIDByCaption(char* name)
{
HWND hwnd = FindWindow(0,name);
if(!hwnd)
return NULL;
DWORD pid;
GetWindowThreadProcessId(hwnd,&pid);
return pid;
}
[/php]
Executable:
[php]
DWORD GetProcessIDByExecutable(char* name)
{
PROCESSENTRY32 Pe;
Pe.dwSize = sizeof( PROCESSENTRY32 );
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPALL,NULL);
Process32First(snapshot,&Pe);
do {
if( !strcmp(Pe.szExeFile,name) )
return Pe.th32ProcessID;
} while(Process32Next(snapshot,&Pe));
return NULL;
}
[/php]