LeeBlog

导航

全屏函数

   在做项目时有时候感觉项目在全屏时运行起来更爽,所以在网上弄了个全屏函数,注意咯:这函数只能在windows下运行,可以做成调用函数

#include <windows.h> 
#include <stdio.h> 
typedef BOOL (WINAPI *PROCGETCONSOLEDISPLAYMODE)(LPDWORD); 
typedef BOOL (WINAPI *PROCSETCONSOLEDISPLAYMODE)(HANDLE,DWORD,LPDWORD); 

PROCGETCONSOLEDISPLAYMODE GetConsoleDisplayMode; 
PROCSETCONSOLEDISPLAYMODE SetConsoleDisplayMode; 

int main() 
{ 
    DWORD dwNewMode=1; 
    DWORD dwOldMode=0; 
    HMODULE hKernel32 = GetModuleHandle("kernel32"); 
    if (!hKernel32) 
       return 0; 
    GetConsoleDisplayMode = (PROCGETCONSOLEDISPLAYMODE) 
    GetProcAddress(hKernel32,"GetConsoleDisplayMode"); 
    if (!GetConsoleDisplayMode) 
       return 0; 
    SetConsoleDisplayMode = (PROCSETCONSOLEDISPLAYMODE) 
    GetProcAddress(hKernel32,"SetConsoleDisplayMode"); 

    if (!SetConsoleDisplayMode) 
       return 0; 
    HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); 
    SetConsoleDisplayMode(hOut,dwNewMode,&dwOldMode); 
    GetConsoleDisplayMode(&dwOldMode); 
    printf("你好啊\n"); 
    getchar() ;
    return 0;
}

posted on 2011-01-31 13:31  LeeBlog  阅读(353)  评论(0编辑  收藏  举报