展开全部
bool scs = AllocConsole();//创建黑窗口
if( !scs )
{
MessageBox(NULL, TEXT("控制台初始化失败"), TEXT("错误"), MB_OK);
exit(0);
}HWND hConsoleWnd = GetConsoleHwnd();//获取控制台
ShowWindow(hConsoleWnd, SW_HIDE);
//......
//以下是GetConsoleHwnd的定义
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
HWND hwndFound; // This is what is returned to the caller.
TCHAR pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated
// WindowTitle.
TCHAR pszOldWindowTitle[MY_BUFSIZE]; // Contains original
// WindowTitle.
// Fetch current window title.
GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
// Format a "unique" NewWindowTitle.
wsprintf(pszNewWindowTitle,TEXT("%d/%d"),
GetTickCount(),