MFC中如何终止ShellExecute调用的外部执行程序?

2024-12-20 20:43:00
推荐回答(1个)
回答1:

HANDLE hProcessHandle;
ULONG nProcessID;
HWND TheWindow;

TheWindow = ::FindWindow( NULL, "你的exe的名称" );
::GetWindowThreadProcessId( TheWindow, &nProcessID );
hProcessHandle =::OpenProcess( PROCESS_TERMINATE,FALSE, nProcessID );
::TerminateProcess( hProcessHandle, 4 );