TerminateProcess() is a handy function -- but it won't kill processes running under LocalSystem (BUILTIN\SYSTEM, to those who like frobbing NT security). Yet the resource kit utility kill.exe manages this. fkill.cpp shows you the trick -- Film At 11!http://win32.mvps.org/processes/fkill.cpp
是你的程序本身要结束掉自己,还是别的程序要结束你的exe???
BOOL TerminateProcess( HANDLE hProcess, // 进程句柄 UINT uExitCode // 退出代码 ); 退出代码可以在其他进程中通过调用GetExitCodeProcess获得。 BOOL GetExitCodeProcess( HANDLE hProcess, // handle to the process LPDWORD lpExitCode // address to receive termination status );如果进程尚未退出,函数将会返回STILL_ACTIVE。
HANDLE hProcess, // 进程句柄
UINT uExitCode // 退出代码
);
退出代码可以在其他进程中通过调用GetExitCodeProcess获得。
BOOL GetExitCodeProcess(
HANDLE hProcess, // handle to the process
LPDWORD lpExitCode // address to receive termination status
);如果进程尚未退出,函数将会返回STILL_ACTIVE。
2. 结束本进程,ExitProcess
3. 如果进程只有一个线程, ExitThread也会退出进程。
SendMessage(hwnd , WM_CLOSE , 0 0 );