关闭DOS窗口
下面是个简单易学的关闭DOS窗口教程,图老师小编详细图解介绍包你轻松学会,喜欢的朋友赶紧get起来吧!
#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();
}