关闭进程 CreateToolhelp32Snapshot
关闭名为"explorer.exe"进程,以下代码为什么没用?
LPCTSTR c_szExplorer = _T("explorer.exe");
HANDLE handle;
PROCESSENTRY32 *FProcessEntry32 = {0};
handle = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,0);
FProcessEntry32->dwSize = sizeof(FProcessEntry32);
if(Process32First(handle,FProcessEntry32))
{
do
{
if (_tcscmp(FProcessEntry32->szExeFile,c_szExplorer) == 0)
{
HANDLE hand;
hand = OpenProcess(PROCESS_ALL_ACCESS,FALSE,FProcessEntry32->th32ProcessID);
TerminateProcess(hand,0);
}
}while(!Process32Next(handle,FProcessEntry32));
CloseHandle(handle);
}
[解决办法]
while(!Process32Next(handle,FProcessEntry32));
你是 !Process32Next 的时候进行:
if (_tcscmp(FProcessEntry32->szExeFile,c_szExplorer) == 0)
{
HANDLE hand;
hand = OpenProcess(PROCESS_ALL_ACCESS,FALSE,FProcessEntry32->th32ProcessID);
TerminateProcess(hand,0);
}
当然没用.感觉像你把西瓜排除在外,买西瓜,当然买不到了哦.