32 lines
768 B
C++
32 lines
768 B
C++
#include "stdafx.h"
|
|
#include "Utility.h"
|
|
|
|
//------------------------------------------
|
|
// 인자로 전달된 이름의 프로세스를 찾는다
|
|
//------------------------------------------
|
|
DWORD FindProcessID( LPCTSTR szProcessName )
|
|
{
|
|
DWORD dwPID = 0xFFFFFFFF;
|
|
HANDLE hSnapShot = INVALID_HANDLE_VALUE;
|
|
PROCESSENTRY32 pe;
|
|
|
|
// Get the snapshot of the system
|
|
pe.dwSize = sizeof( PROCESSENTRY32 );
|
|
hSnapShot = CreateToolhelp32Snapshot( TH32CS_SNAPALL, NULL );
|
|
|
|
// find process
|
|
Process32First(hSnapShot, &pe);
|
|
do
|
|
{
|
|
if(!_stricmp(szProcessName, pe.szExeFile))
|
|
{
|
|
dwPID = pe.th32ProcessID;
|
|
break;
|
|
}
|
|
}
|
|
while( Process32Next(hSnapShot, &pe ) );
|
|
|
|
CloseHandle(hSnapShot);
|
|
|
|
return dwPID;
|
|
} |