怎么将PPC的屏幕关黑

Posted on 2007-09-07 16:12  啊夏  阅读(417)  评论(0)    收藏  举报
网上收刮来的代码,在这里做个记录。

//   display.cpp   :   Defines   the   entry   point   for   the   application.   
  
//   
    
  #include   
"stdafx.h"   
  #include   
"display.h"   
  #include   
<commctrl.h>   
  #include   
<aygshell.h>   
  #include   
<sipapi.h>   
  #include   
<wingdi.h>   
    
  
//   GDI   Escapes   for   ExtEscape()   
  #define   QUERYESCSUPPORT         8   
      
  
//   The   following   are   unique   to   CE   
  #define   GETVFRAMEPHYSICAL       6144   
  
#define   GETVFRAMELEN         6145   
  
#define   DBGDRIVERSTAT         6146   
  
#define   SETPOWERMANAGEMENT       6147   
  
#define   GETPOWERMANAGEMENT       6148   
      
    
  typedef   
enum   _VIDEO_POWER_STATE   {   
          VideoPowerOn   
=   1,   
          VideoPowerStandBy,   
          VideoPowerSuspend,   
          VideoPowerOff   
  }
   VIDEO_POWER_STATE,   *PVIDEO_POWER_STATE;   
      
    
  typedef   
struct   _VIDEO_POWER_MANAGEMENT   {   
          ULONG   Length;   
          ULONG   DPMSVersion;   
          ULONG   PowerState;   
  }
   VIDEO_POWER_MANAGEMENT,   *PVIDEO_POWER_MANAGEMENT;   
    
    
  
int   WINAPI   WinMain(   
          HINSTANCE   hInstance,   
          HINSTANCE   hPrevInstance,   
          LPTSTR         lpCmdLine,   
          
int               nCmdShow   
  )   
  
{   
          HDC   gdc;   
          VIDEO_POWER_MANAGEMENT   vpm   
=   {   0   };   
          
int   iESC=SETPOWERMANAGEMENT;   
    
    
          gdc   
=   ::GetDC(NULL);   
    
          
if   (ExtEscape(gdc,   8,   sizeof(int),   (LPCSTR)&iESC,   0,   NULL)==0)   
          
{   
                  MessageBox(   
                          NULL,   
                          L
"DO   not   support   DisplayOFF/ON",   
                          L
"Code   by   Arac",   
                          MB_OK   
                  );   
                  
goto   Exit0;   
          }
   
            
          vpm.DPMSVersion   
=   0x0001;   
          vpm.Length   
=   sizeof(VIDEO_POWER_MANAGEMENT);   
    
          vpm.PowerState   
=   VideoPowerOff;   
          ExtEscape(gdc,   SETPOWERMANAGEMENT,   vpm.Length,   (LPCSTR)   
&vpm,   0,   NULL);   
    
  Exit0:   
          ::ReleaseDC(NULL,   gdc);   
          
return   0;   
  }