#include <windows.h>
void __fastcall KillProcess(HWND hWnd)
{
DWORD* pPid;
DWORD result;
void *hg;
hg = GlobalAlloc(GMEM_SHARE, sizeof(DWORD));
pPid =(DWORD *)GlobalLock(hg);
result = GetWindowThreadProcessId(hWnd, pPid);
if(result)
{
HANDLE ps = OpenProcess(1, false, *pPid);
TerminateProcess(ps, -9);
GlobalUnlock(hg);
GlobalFree(hg);
}
}
void __fastcall CloseDosWindow()
{
HWND hWnd=FindWindow("ConsoleWindowClass",NULL);//這個是2000的,98下用"tty"
KillProcess(hWnd);
return;
}
int main()
{
CloseDosWindow();
}