【 tulaoshi.com - 编程语言 】
//http://nowcan.yeah.net
#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();
}