c语言输出窗口最大化,WIN32API之最大化console — C语言描述

原理:先获取console窗口的handle,再控制其最大化

编译环境:vc++7

平台:win2000以上

#define _WIN32_WINNT 0x0500

/* 要先定义windows版本,win2000是5.0  */

#include

#include

/* 这个程序的功能是最大化当前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();

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值