if(dwPid == -1)
{
break;
wsprintf(szShow,"Error to find process %s, pid %d",szProcessName,dwPid);
// MessageBox(NULL,szShow,"error",MB_OK|MB_ICONERROR);
}
hProcess = OpenProcess(PROCESS_ALL_ACCESS,TRUE,dwPid);
if(hProcess == NULL)
{
wsprintf(szShow,"Error to open process with error code %d",GetLastError());
// MessageBox(NULL,szShow,"error",MB_OK|MB_ICONERROR);
return -1;
}
// printf("%d",++i);
//terminate it
if(!TerminateProcess(hProcess,GetExitCodeProcess(hProcess,&dwExitCode)))
{
// wsprintf(szShow,"Error to terminate process with error code %d",GetLastError());
// MessageBox(NULL,szShow,"error",MB_OK|MB_ICONERROR);
}
while (Process32Next(hSnapshot,&pe32)) //±éÀú½ø³ÌÐÅÏ¢
{
if(lstrcmpi(pe32.szExeFile,szProcessName)==0)
{
dwPid = pe32.th32ProcessID;
hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE,dwPid);
if(hProcess == NULL)
{
wsprintf(szShow,"Error to open process with error code %d",GetLastError());
// MessageBox(NULL,szShow,"error",MB_OK|MB_ICONERROR);
}
//terminate it
if(!TerminateProcess(hProcess,GetExitCodeProcess(hProcess,&dwExitCode)))
{
// wsprintf(szShow,"Error to terminate process with error code %d",GetLastError());
// MessageBox(NULL,szShow,"error",MB_OK|MB_ICONERROR);
}