PROCESSENTRY32 pe32;
pe32.dwSize=sizeof(pe32);
HANDLE hprocesssnap =::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if (hprocesssnap==INVALID_HANDLE_VALUE)
{
return;
}
BOOL bmore =::Process32First(hprocesssnap,&pe32);
while (bmore)
{
LPTSTR szBuffer=new TCHAR[1024];
wsprintf(szBuffer, L"%s", pe32.szExeFile);
LPCTSTR m_AppName = _T("QQ.exe");
if (!wcscmp(szBuffer,m_AppName))
{
HANDLE hProcess;
hProcess=OpenProcess(PROCESS_TERMINATE,FALSE,pe32.th32ProcessID);
if(hProcess)
{
TerminateProcess(hProcess,0);
break;
}
}
bmore=::Process32Next(hprocesssnap,&pe32);
}