琪依坤 | 羽毛在飛

Good Luck To You!

调节亮度

#define REG_BACKLIGHT L"ControlPanel//Backlight"
#define REG_VAL_BATT_TO L"BatteryTimeout"
#define REG_VAL_AC_TO L"ACTimeout"
#define REG_VAL_BN_TO L"BrightNess"
#define REG_VAL_ACBN_TO L"ACBrightness"

unsigned int OldBattBL=0;
unsigned int OldACBL=0;

void RegOptionBLTimeout( BOOL Disable,DWORD dw1,DWORD dw2)
{
 HKEY hKey = 0;
 DWORD dwSize;
 DWORD dwValue;
 HANDLE hBL;

 if ( ERROR_SUCCESS == RegOpenKeyEx( HKEY_CURRENT_USER,REG_BACKLIGHT, 0, 0, &hKey ) )
 {

  if( Disable )
  {
   dwSize = 4;
   RegQueryValueEx( hKey, REG_VAL_BATT_TO,NULL,NULL,(unsigned char*) &OldBattBL,&dwSize );dwSize = 4;RegQueryValueEx( hKey, REG_VAL_AC_TO,NULL,NULL,(unsigned char*) &OldACBL,&dwSize );

  // dwSize = 4;
  // dwValue = 0xefff ;
  // RegSetValueEx( hKey,REG_VAL_BATT_TO,NULL,REG_DWORD,(unsigned char *)&dwValue,dwSize );
  // dwSize = 4;
  // dwValue = 0xefff ;
  // RegSetValueEx( hKey,REG_VAL_AC_TO,NULL,REG_DWORD,(unsigned char *)&dwValue,dwSize );

   dwSize = 4;
   RegSetValueEx( hKey,REG_VAL_BN_TO,NULL,REG_DWORD,(unsigned char *)&dw1,dwSize );
   dwSize = 4;
   RegSetValueEx( hKey,REG_VAL_ACBN_TO,NULL,REG_DWORD,(unsigned char *)&dw2,dwSize );
  }
  else
  {
   if (OldBattBL)
   {
    dwSize = 4;
    RegSetValueEx( hKey,REG_VAL_BN_TO,NULL,REG_DWORD,(unsigned char *)&OldBattBL,dwSize );
   }
   if (OldACBL)
   {
    dwSize = 4;
    RegSetValueEx( hKey,REG_VAL_ACBN_TO,NULL,REG_DWORD,(unsigned char *)&OldACBL,dwSize );
   }
  }

  RegCloseKey( hKey );
  hBL = CreateEvent( NULL, FALSE, FALSE,L"BackLightChangeEvent" );
  if( hBL )
  {
   SetEvent(hBL);
   CloseHandle( hBL );
  }
 }
}

//设置

RegOptionBLTimeout(TRUE,m_edit1,m_edit2);

 

更多精彩请关注公众号:

发表评论:

Powered By Z-BlogPHP 1.7.2

沪ICP备12032294号-1