ReadPwrScheme ... WritePwrScheme

Everything else that doesn't fall into one of the other PB categories.
User avatar
bingo
Enthusiast
Enthusiast
Posts: 210
Joined: Fri Apr 02, 2004 12:21 pm
Location: germany/thueringen
Contact:

ReadPwrScheme ... WritePwrScheme

Post by bingo »

read powerscheme "4" and write it as "9" with new name/description .

Code: Select all

Structure POWER_ACTION_POLICY
Action.l
Flags.l
EventCode.l
EndStructure 

Structure MACHINE_POWER_POLICY
Revision.l
MinSleepAc.l
MinSleepDc.l
ReducedLatencySleepAc.l
ReducedLatencySleepDc.l
DozeTimeoutAc.l
DozeTimeoutDc.l
DozeS4TimeoutAc.l
DozeS4TimeoutDc.l
MinThrottleAc.b
MinThrottleDc.b
pad1.b[2]
OverThrottledAc.POWER_ACTION_POLICY
OverThrottledDc.POWER_ACTION_POLICY
EndStructure 

Structure USER_POWER_POLICY
Revision.l
IdleAc.POWER_ACTION_POLICY
IdleDc.POWER_ACTION_POLICY
IdleTimeoutAc.l
IdleTimeoutDc.l
IdleSensitivityAc.b
IdleSensitivityDc.b
ThrottlePolicyAc.b
ThrottlePolicyDc.b
MaxSleepAc.l
MaxSleepDc.l
Reserved.l[2]
VideoTimeoutAc.l
VideoTimeoutDc.l
SpindownTimeoutAc.l
SpindownTimeoutDc.l
OptimizeForPowerAc.b
OptimizeForPowerDc.b
FanThrottleToleranceAc.b
FanThrottleToleranceDc.b
ForcedThrottleAc.b
ForcedThrottleDc.b
EndStructure 

Structure POWER_POLICY
user.USER_POWER_POLICY
mach.MACHINE_POWER_POLICY
EndStructure 


PP.POWER_POLICY


OpenLibrary(1, "PowrProf.DLL")
F1 = IsFunction(1, "ReadPwrScheme")
F2 = IsFunction(1, "WritePwrScheme")

CallFunctionFast(F1,4,@PP)

scheme.s = "scheme 9"

schemeinfo.s = "scheme 9 info"

Debug CallFunctionFast(F2,9,@scheme,@schemeinfo,@PP) ;<- crash !
CloseLibrary(1) 
http://msdn.microsoft.com/library/defau ... scheme.asp

the code crashs on WritePwrScheme :cry: - any hints ?
["1:0>1"]
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post by MrMat »

The 9 in CallFunctionFast(F2,9,@scheme,@schemeinfo,@PP) should be a pointer to a long so you could have:

Code: Select all

schemenum.l = 9
CallFunctionFast(F2,@schemenum,@scheme,@schemeinfo,@PP)
Also the strings scheme and schemeinfo should be converted to unicode first. It seems to work ok if you use the code from http://www.purearea.net/pb/CodeArchiv/S ... Unicode.pb to convert them. Hope you get it working!
Mat
User avatar
bingo
Enthusiast
Enthusiast
Posts: 210
Joined: Fri Apr 02, 2004 12:21 pm
Location: germany/thueringen
Contact:

Post by bingo »

ok ... maybe a bug in this msdn-doc
http://msdn.microsoft.com/library/defau ... scheme.asp


lpszName
[in] Pointer to a null-terminated string that specifies the name of the power scheme.
lpszDescription
[in] Pointer to a null-terminated string that specifies the description of the power scheme.


but works with unicode ONLY ! thanks :wink:
["1:0>1"]
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post by MrMat »

Those are the names of the variables. Their types in the box above show the strings are unicode so i don't think it's a bug:

Code: Select all

BOOLEAN WritePwrScheme(
  PUINT puiID,
  LPWSTR lpszName,
  LPWSTR lpszDescription,
  PPOWER_POLICY pPowerPolicy
);
Hope you got it working! :)
Mat
Post Reply