原理:先获取console窗口的handle,再控制其最大化
编译环境:vc++7
平台:win2000以上
#define _WIN32_WINNT 0x0500
/* 要先定义windows版本,win2000是5.0 */
#include <windows.h>
#include <stdio.h>
/* 这个程序的功能是最大化当前console窗口,不过只能运行在2000/xp/2003 */
/*
GetConsoleWindow:
The GetConsoleWindow function retrieves the window handle used by the console associated with the calling process.
Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Header: Declared in Wincon.h; include Windows.h.
Library: Use Kernel32.lib.
*/
void main()
{
HWND hConsole;
hConsole=GetConsoleWindow(); /* 获取当前console窗口句柄,然后就可以对这个窗口进行你喜欢的操作 */
if ( hConsole==NULL )
{
printf("ERROR./n"); /* 不成功 */
}
else {
ShowWindow(hConsole,SW_SHOWMAXIMIZED); /* 最大化窗口 */
/* 说明,最大化也是一种full screen,参见:
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/dllproc/base/getconsoledisplaymode.htm */
}
printf("Press ENTER to continue.../n");
getchar();
}