一个关闭显示器的程序源码

 

XP下编译通过使用

 

#define WIN32_LEAN_AND_MEAN

#include 

#include "resource.h"

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    PSTR szCmdLine, int iCmdShow)
{
    static TCHAR szAppName[] = TEXT("LcdDown") ;
    HWND hwnd ;
    WNDCLASS wndclass ;

    wndclass.style = CS_HREDRAW | CS_VREDRAW ;
    wndclass.lpfnWndProc = DefWindowProc ;
    wndclass.cbClsExtra = 0 ;
    wndclass.cbWndExtra = 0 ;
    wndclass.hInstance = hInstance ;
    wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION) ;
    wndclass.hCursor = LoadCursor(NULL, IDC_ARROW) ;
    wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH) ;
    wndclass.lpszMenuName = NULL ;
    wndclass.lpszClassName = szAppName ;

    if (!RegisterClass(&wndclass))
    {
        MessageBox(NULL, TEXT("This program requires Windows NT!"), szAppName,
            MB_ICONERROR) ;
        return 0 ;
    }

    hwnd = CreateWindow(szAppName, TEXT("LcdDown"), WS_OVERLAPPEDWINDOW,
            CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
            NULL, hInstance, NULL) ;

    ShowWindow(hwnd, 0) ;
    UpdateWindow(hwnd) ;

    Sleep(1000);
    SendMessage(hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, 2);

    return 0;
}

 

附件为编译的程序

 

 

 

 

 

你可能感兴趣的:(XP,Windows)