DWORD DisableDisplayPowerXP(bool bDisable)
{
DWORD dwRet = 0;
static const UINT nId = 100;
static UINT nOriginalValue = 0;
static BOOL bModify = FALSE;
if (bDisable)
{
if (!bModify)
{
POWER_POLICY policy = {0};
GetActivePwrScheme(&nOriginalValue);
if (!ReadPwrScheme(nOriginalValue, &policy))
{
dwRet = GetLastError();
goto _Exit;
}
//显示器
policy.user.VideoTimeoutAc = 0;
policy.user.VideoTimeoutDc = 0;
//硬盘
policy.user.SpindownTimeoutAc = 0;
policy.user.SpindownTimeoutDc = 0;
//休眠
policy.mach.DozeS4TimeoutAc=0;
policy.mach.DozeS4TimeoutDc=0;
//待机
policy.user.IdleTimeoutAc = 0;
policy.user.IdleTimeoutDc = 0;
if (!WritePwrScheme((PUINT)&nId, _T("FUCKPOWER"), _T("FUCKPOWER"), &policy))
{
dwRet = GetLastError();
goto _Exit;
}
if (!SetActivePwrScheme(nId, NULL, NULL))
{
dwRet = GetLastError();
DeletePwrScheme(nId);
goto _Exit;
}
bModify = TRUE;
}
}
else
{
if (bModify)
{
bModify = FALSE;
if (nOriginalValue != nId)
{
if (!SetActivePwrScheme(nOriginalValue, NULL, NULL))
{
dwRet = GetLastError();
}
DeletePwrScheme(nId);
}
}
}
_Exit:
return dwRet;
}
keivin2006
认证博客专家
C/C
vc/qt
音视频
一名c/c++/vc/qt 的小学生,“精通”c,“精通”c++,“精通”vc++,“精通”php,“精通”qt,“精通”java,“精通”python,“精通”c#,“精通”...! 编不下去了,只要见过名字的都我“精通”....为哈,因为我现在是csdn“砖家”了!本人qq: 88520350 qq学习群:930432714 (C/C++/QT/VC学习交流群) 海量学习资料都分享在群里指点学习方向,掌握学习要点,快速提高技术水平, 技术分享,共同学习!