BOOL KillProcess ( HWND hWnd, LPTSTR lpAppName )
{
TCHAR szApp [MAX_PATH] = _T("")
_tcscpy ( szApp, lpAppName )
PROCESSENTRY32 pe32
pe32.dwSize = sizeof( pe32 )
HANDLE hProcessSnap = ::CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 )
if ( hProcessSnap == INVALID_HANDLE_VALUE )
{
MessageBox( hWnd, L"Can't Create Snapshot", L"System Info.", NULL )
return FALSE
}
BOOL bNext = ::Process32First( hProcessSnap, &pe32 )
while( bNext )
{
if( _tcscmp ( CharLower ( pe32.szExeFile ), CharLower ( szApp )) == 0 )
{
HANDLE hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID )
TerminateProcess( hProcess, 0 )
}
bNext = ::Process32Next( hProcessSnap,&pe32 )
}
CloseHandle( hProcessSnap )
return TRUE
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)