📄 utilities.cpp
字号:
/***************************************************************************************
*This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* The GPL can be found at: http://www.gnu.org/copyleft/gpl.html *
* *
* *
****************************************************************************************
* Authors: *
* Marc Dukette *
**************************************************************************************/
#include "stdafx.h"
#include <commctrl.h>
#if (_WIN32_WCE >= 300)
//// 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
#define REG_BACKLIGHT L"ControlPanel\\Backlight"
#define REG_VAL_BATT_TO L"BatteryTimeout"
#define REG_VAL_AC_TO L"ACTimeout"
unsigned int OldBattBL=0;
unsigned int OldACBL=0;
typedef struct _VIDEO_POWER_MANAGEMENT {
ULONG Length;
ULONG DPMSVersion;
ULONG PowerState;
} VIDEO_POWER_MANAGEMENT, *PVIDEO_POWER_MANAGEMENT;
VIDEO_POWER_MANAGEMENT vpm={0,0,1};
//
// function to disable/enable backlight timeout
//
void RegOptionBLTimeout( BOOL Disable )
{
HKEY hKey = 0;
DWORD dwSize;
DWORD dwValue;
HANDLE hBL;
if (vpm.PowerState == 4) return;
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 );
}
else
{
if (OldBattBL)
{
dwSize = 4;
RegSetValueEx( hKey,REG_VAL_BATT_TO,NULL,REG_DWORD,(unsigned char *)&OldBattBL,dwSize );
}
if (OldACBL)
{
dwSize = 4;
RegSetValueEx( hKey,REG_VAL_AC_TO,NULL,REG_DWORD,(unsigned char *)&OldACBL,dwSize );
}
}
RegCloseKey( hKey );
hBL = CreateEvent( NULL, FALSE, FALSE,L"BackLightChangeEvent" );
if( hBL )
{
SetEvent(hBL);
CloseHandle( hBL );
}
}
}
void ToggleDisplay()
{
HDC gdc;
int iESC=SETPOWERMANAGEMENT;
gdc = ::GetDC(NULL);
vpm.Length = sizeof(VIDEO_POWER_MANAGEMENT);
vpm.DPMSVersion = 0x0001;
if (vpm.PowerState == 1)
{
vpm.PowerState = 4;
}
else
{
vpm.PowerState = 1;
}
ExtEscape(gdc, SETPOWERMANAGEMENT, vpm.Length, (LPCSTR) &vpm,
0, NULL);
::ReleaseDC(NULL, gdc);
}
#endif
#ifdef MIPS
int MyGetTickCount()
{
SYSTEMTIME t;
GetSystemTime(&t);
return (t.wDay*24*60*60*1000)+(t.wHour*60*60*1000) + (t.wMinute*60*1000) + (t.wSecond*1000) + t.wMilliseconds;
}
#endif
void GetFileExt(LPTSTR File,LPTSTR EXT)
{
LPTSTR temp=File;
int dcnt=0;
int done=0;
int found=0;
int n=wcslen(File);
while (!done&&(n>=0))
{
if (File[n]==L'.')
{
found=1;
done=1;
continue;
}
if (File[n]==L'/')
{
done=1;
continue;
}
n--;
}
if (found&&(n>0))
{
wcscpy(EXT,File+n+1);
}
else
{
wcscpy(EXT,_T(""));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -