It is currently Thu Nov 21, 2019 2:06 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Windows Powrprof API
PostPosted: Wed Jun 19, 2019 9:01 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4425
Location: Germany
Hi,

I translated the stuff from
https://github.com/Ravatsaas/PowerManag ... ManagerAPI

Code:
CompilerIf #PB_Compiler_IsMainFile
  EnableExplicit
CompilerEndIf


; https://docs.microsoft.com/en-us/windows/desktop/api/powersetting/
; https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/

; https://github.com/Ravatsaas/PowerManagerAPI


Enumeration ErrorCode
  #SUCCESS                 = $000
  #FILE_NOT_FOUND          = $002
  #ERROR_INVALID_PARAMETER = $057
  #ERROR_ALREADY_EXISTS    = $0B7
  #MORE_DATA               = $0EA
  #NO_MORE_ITEMS           = $103
EndEnumeration

Enumeration AccessFlags
  #ACCESS_SCHEME = 16
  #ACCESS_SUBGROUP = 17
  #ACCESS_INDIVIDUAL_SETTING = 18
EndEnumeration

Enumeration PowerMode
  #AC = 1
  #DC = 2
EndEnumeration


Enumeration SettingSubgroup
  #NO_SUBGROUP
  #DISK_SUBGROUP
  #SYSTEM_BUTTON_SUBGROUP
  #PROCESSOR_SETTINGS_SUBGROUP
  #VIDEO_SUBGROUP
  #BATTERY_SUBGROUP
  #SLEEP_SUBGROUP
  #PCIEXPRESS_SETTINGS_SUBGROUP
EndEnumeration

Enumeration Setting
  #BATACTIONCRIT
  #BATACTIONLOW
  #BATFLAGSLOW
  #BATLEVELCRIT
  #BATLEVELLOW
  #LIDACTION
  #PBUTTONACTION
  #SBUTTONACTION
  #UIBUTTON_ACTION
  #DISKIDLE
  #ASPM
  #PROCFREQMAX
  #PROCTHROTTLEMAX
  #PROCTHROTTLEMIN
  #SYSCOOLPOL
  #HIBERNATEIDLE
  #HYBRIDSLEEP
  #RTCWAKE
  #STANDBYIDLE
  #ADAPTBRIGHT
  #VIDEOIDLE
EndEnumeration


CompilerIf Defined(GUID, #PB_Structure) = #False
  Structure GUID
    Data1.l
    Data2.w
    Data3.w
    Data4.b[8]
  EndStructure
CompilerEndIf


Prototype.l Prototype_PowerGetActiveScheme(UserPowerKey.l, *ActivePolicyGuid.GUID)
Prototype.l Prototype_PowerSetActiveScheme(UserPowerKey.l, *ActivePolicyGuid.GUID)
Prototype.l Prototype_PowerReadFriendlyName(RootPowerKey.l, *SchemeGuid.GUID, *SubGroupOfPowerSettingsGuid.GUID, *PowerSettingGuid.GUID, *Buffer, *BufferSize)
Prototype.l Prototype_PowerWriteFriendlyName(RootPowerKey.l, *SchemeGuid.GUID, *SubGroupOfPowerSettingsGuid.GUID, *PowerSettingGuid.GUID, Buffer.p-unicode, BufferSize.l)
Prototype.l Prototype_PowerEnumerate(RootPowerKey.l, *SchemeGuid.GUID, *SubGroupOfPowerSettingsGuid.GUID, AccessFlags.l, Index.l, *Buffer, *BufferSize)
Prototype.l Prototype_PowerReadDescription(RootPowerKey.l, *SchemeGuid.GUID, *SubGroupOfPowerSettingsGuid.GUID, *PowerSettingGuid.GUID, *Buffer, *BufferSize)
Prototype.l Prototype_PowerWriteDescription(RootPowerKey.l, *SchemeGuid.GUID, *SubGroupOfPowerSettingsGuid.GUID, *PowerSettingGuid.GUID, Buffer.p-unicode, BufferSize.l)
Prototype.l Prototype_PowerReadACValueIndex(RootPowerKey.l, *SchemeGuid.GUID, *SubGroupOfPowerSettingsGuid.GUID, *PowerSettingGuid.GUID, *AcValueIndex)
Prototype.l Prototype_PowerWriteACValueIndex(RootPowerKey.l, *SchemeGuid.GUID, *SubGroupOfPowerSettingsGuid.GUID, *PowerSettingGuid.GUID, AcValueIndex)
Prototype.l Prototype_PowerReadDCValueIndex(RootPowerKey.l, *SchemeGuid.GUID, *SubGroupOfPowerSettingsGuid.GUID, *PowerSettingGuid.GUID, *DcValueIndex)
Prototype.l Prototype_PowerWriteDCValueIndex(RootPowerKey.l, *SchemeGuid.GUID, *SubGroupOfPowerSettingsGuid.GUID, *PowerSettingGuid.GUID, DcValueIndex)
Prototype.l Prototype_PowerDeleteScheme(RootPowerKey.l, *SchemeGuid.GUID)
Prototype.l Prototype_PowerDuplicateScheme(RootPowerKey.l, *SourceSchemeGuid.GUID, *DestinationSchemeGuid.GUID)


Global PowerGetActiveScheme.Prototype_PowerGetActiveScheme
Global PowerSetActiveScheme.Prototype_PowerSetActiveScheme
Global PowerReadFriendlyName.Prototype_PowerReadFriendlyName
Global PowerWriteFriendlyName.Prototype_PowerWriteFriendlyName
Global PowerEnumerate.Prototype_PowerEnumerate
Global PowerReadDescription.Prototype_PowerReadDescription
Global PowerWriteDescription.Prototype_PowerWriteDescription
Global PowerReadACValueIndex.Prototype_PowerReadACValueIndex
Global PowerWriteACValueIndex.Prototype_PowerWriteACValueIndex
Global PowerReadDCValueIndex.Prototype_PowerReadDCValueIndex
Global PowerWriteDCValueIndex.Prototype_PowerWriteDCValueIndex
Global PowerDeleteScheme.Prototype_PowerDeleteScheme
Global PowerDuplicateScheme.Prototype_PowerDuplicateScheme


Procedure.s PowrProf_GUIDToString(*GUID.GUID)
 
  Protected GUID$, i.i
 
 
  GUID$ = RSet(Hex(*GUID\Data1, #PB_Long), 8, "0") + "-"
  GUID$ + RSet(Hex(*GUID\Data2, #PB_Word), 4, "0") + "-"
  GUID$ + RSet(Hex(*GUID\Data3, #PB_Word), 4, "0") + "-"
  GUID$ + RSet(Hex(*GUID\Data4[0], #PB_Byte), 2, "0")
  GUID$ + RSet(Hex(*GUID\Data4[1], #PB_Byte), 2, "0") + "-"
  For i = 2 To 7
    GUID$ + RSet(Hex(*GUID\Data4[i], #PB_Byte), 2, "0")
  Next i
 
  ProcedureReturn GUID$
 
EndProcedure


Procedure PowrProf_StringToGUID(GUID$, *GUID.GUID)
 
  Protected i.i
 
 
  *GUID\Data1 = Val("$" + Left(GUID$, 8))
  *GUID\Data2 = Val("$" + Mid(GUID$, 10, 4))
  *GUID\Data3 = Val("$" + Mid(GUID$, 15, 4))
  *GUID\Data4[0] = Val("$" + Mid(GUID$, 20, 2))
  *GUID\Data4[1] = Val("$" + Mid(GUID$, 22, 2))
  For i = 2 To 7
    *GUID\Data4[i] = Val("$" + Mid(GUID$, 25 + (i - 2) * 2, 2))
  Next i
 
EndProcedure


Global PowrProf_Lib.i

Global NewMap SettingSubgroup.GUID()
Global NewMap Setting.GUID()


Procedure.i PowrProf_Init()
 
  If PowrProf_Lib = 0
    PowrProf_Lib = OpenLibrary(#PB_Any, "powrprof.dll")
    If PowrProf_Lib
     
      PowerGetActiveScheme = GetFunction(PowrProf_Lib, "PowerGetActiveScheme")
      PowerSetActiveScheme = GetFunction(PowrProf_Lib, "PowerSetActiveScheme")
      PowerReadFriendlyName = GetFunction(PowrProf_Lib, "PowerReadFriendlyName")
      PowerWriteFriendlyName = GetFunction(PowrProf_Lib, "PowerWriteFriendlyName")
      PowerEnumerate = GetFunction(PowrProf_Lib, "PowerEnumerate")
      PowerReadDescription = GetFunction(PowrProf_Lib, "PowerReadDescription")
      PowerWriteDescription = GetFunction(PowrProf_Lib, "PowerWriteDescription")
      PowerReadACValueIndex = GetFunction(PowrProf_Lib, "PowerReadACValueIndex")
      PowerWriteACValueIndex = GetFunction(PowrProf_Lib, "PowerWriteACValueIndex")
      PowerReadDCValueIndex = GetFunction(PowrProf_Lib, "PowerReadDCValueIndex")
      PowerWriteDCValueIndex = GetFunction(PowrProf_Lib, "PowerWriteDCValueIndex")
      PowerDeleteScheme = GetFunction(PowrProf_Lib, "PowerDeleteScheme")
      PowerDuplicateScheme = GetFunction(PowrProf_Lib, "PowerDuplicateScheme")
     
     
      AddMapElement(SettingSubgroup(), Str(#NO_SUBGROUP))
      PowrProf_StringToGUID("fea3413e-7e05-4911-9a71-700331f1c294", SettingSubgroup())
     
      AddMapElement(SettingSubgroup(), Str(#DISK_SUBGROUP))
      PowrProf_StringToGUID("0012ee47-9041-4b5d-9b77-535fba8b1442", SettingSubgroup())
     
      AddMapElement(SettingSubgroup(), Str(#SYSTEM_BUTTON_SUBGROUP))
      PowrProf_StringToGUID("4f971e89-eebd-4455-a8de-9e59040e7347", SettingSubgroup())
     
      AddMapElement(SettingSubgroup(), Str(#PROCESSOR_SETTINGS_SUBGROUP))
      PowrProf_StringToGUID("54533251-82be-4824-96c1-47b60b740d00", SettingSubgroup())
     
      AddMapElement(SettingSubgroup(), Str(#VIDEO_SUBGROUP))
      PowrProf_StringToGUID("7516b95f-f776-4464-8c53-06167f40cc99", SettingSubgroup())
     
      AddMapElement(SettingSubgroup(), Str(#BATTERY_SUBGROUP))
      PowrProf_StringToGUID("e73a048d-bf27-4f12-9731-8b2076e8891f", SettingSubgroup())
     
      AddMapElement(SettingSubgroup(), Str(#SLEEP_SUBGROUP))
      PowrProf_StringToGUID("238C9FA8-0AAD-41ED-83F4-97BE242C8F20", SettingSubgroup())
     
      AddMapElement(SettingSubgroup(), Str(#PCIEXPRESS_SETTINGS_SUBGROUP))
      PowrProf_StringToGUID("501a4d13-42af-4429-9fd1-a8218c268e20", SettingSubgroup())
     
     
      AddMapElement(Setting(), Str(#BATACTIONCRIT))
      PowrProf_StringToGUID("637ea02f-bbcb-4015-8e2c-a1c7b9c0b546", Setting())
     
      AddMapElement(Setting(), Str(#BATACTIONLOW))
      PowrProf_StringToGUID("d8742dcb-3e6a-4b3c-b3fe-374623cdcf06", Setting())
     
      AddMapElement(Setting(), Str(#BATFLAGSLOW))
      PowrProf_StringToGUID("bcded951-187b-4d05-bccc-f7e51960c258", Setting())
     
      AddMapElement(Setting(), Str(#BATLEVELCRIT))
      PowrProf_StringToGUID("9a66d8d7-4ff7-4ef9-b5a2-5a326ca2a469", Setting())
     
      AddMapElement(Setting(), Str(#BATLEVELLOW))
      PowrProf_StringToGUID("8183ba9a-e910-48da-8769-14ae6dc1170a", Setting())
     
      AddMapElement(Setting(), Str(#LIDACTION))
      PowrProf_StringToGUID("5ca83367-6e45-459f-a27b-476b1d01c936", Setting())
     
      AddMapElement(Setting(), Str(#PBUTTONACTION))
      PowrProf_StringToGUID("7648efa3-dd9c-4e3e-b566-50f929386280", Setting())
     
      AddMapElement(Setting(), Str(#SBUTTONACTION))
      PowrProf_StringToGUID("96996bc0-ad50-47ec-923b-6f41874dd9eb", Setting())
     
      AddMapElement(Setting(), Str(#UIBUTTON_ACTION))
      PowrProf_StringToGUID("a7066653-8d6c-40a8-910e-a1f54b84c7e5", Setting())
     
      AddMapElement(Setting(), Str(#DISKIDLE))
      PowrProf_StringToGUID("6738e2c4-e8a5-4a42-b16a-e040e769756e", Setting())
     
      AddMapElement(Setting(), Str(#ASPM))
      PowrProf_StringToGUID("ee12f906-d277-404b-b6da-e5fa1a576df5", Setting())
     
      AddMapElement(Setting(), Str(#PROCFREQMAX))
      PowrProf_StringToGUID("75b0ae3f-bce0-45a7-8c89-c9611c25e100", Setting())
     
      AddMapElement(Setting(), Str(#PROCTHROTTLEMAX))
      PowrProf_StringToGUID("bc5038f7-23e0-4960-96da-33abaf5935ec", Setting())
     
      AddMapElement(Setting(), Str(#PROCTHROTTLEMIN))
      PowrProf_StringToGUID("893dee8e-2bef-41e0-89c6-b55d0929964c", Setting())
     
      AddMapElement(Setting(), Str(#SYSCOOLPOL))
      PowrProf_StringToGUID("94d3a615-a899-4ac5-ae2b-e4d8f634367f", Setting())
     
      AddMapElement(Setting(), Str(#HIBERNATEIDLE))
      PowrProf_StringToGUID("9d7815a6-7ee4-497e-8888-515a05f02364", Setting())
     
      AddMapElement(Setting(), Str(#HYBRIDSLEEP))
      PowrProf_StringToGUID("94ac6d29-73ce-41a6-809f-6363ba21b47e", Setting())
     
      AddMapElement(Setting(), Str(#RTCWAKE))
      PowrProf_StringToGUID("bd3b718a-0680-4d9d-8ab2-e1d2b4ac806d", Setting())
     
      AddMapElement(Setting(), Str(#STANDBYIDLE))
      PowrProf_StringToGUID("29f6c1db-86da-48c5-9fdb-f2b67b1f44da", Setting())
     
      AddMapElement(Setting(), Str(#ADAPTBRIGHT))
      PowrProf_StringToGUID("fbd9aa66-9553-4097-ba44-ed6e9d65eab8", Setting())
     
      AddMapElement(Setting(), Str(#VIDEOIDLE))
      PowrProf_StringToGUID("3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e", Setting())
     
    EndIf
  EndIf
 
  ProcedureReturn PowrProf_Lib
 
EndProcedure


Procedure PowrProf_Close()
  If PowrProf_Lib
    CloseLibrary(PowrProf_Lib)
    PowrProf_Lib = 0
    ClearMap(SettingSubgroup())
    ClearMap(Setting())
  EndIf
EndProcedure


Procedure.s GetActivePlan()
 
  Protected GUID$, Result.i, *GUID.GUID
 
 
  Result = PowerGetActiveScheme(#Null, @*GUID)
  If Result = #SUCCESS
    GUID$ = PowrProf_GUIDToString(*GUID)
    LocalFree_(*GUID)
  EndIf
 
  ProcedureReturn GUID$
 
EndProcedure




Procedure.i SetActivePlan(GUID$)
 
  Protected Result.i, TempGuid.GUID
 
 
  PowrProf_StringToGUID(GUID$, @TempGuid)
  Result = PowerSetActiveScheme(#Null, @TempGuid)
  If Result = #SUCCESS
    Result = #True
  Else
    Result = #False
  EndIf
 
  ProcedureReturn Result
 
EndProcedure




Procedure.s GetPlanName(GUID$)
 
  Protected Name$, Result.i, *Buffer, BufferSize.i, TempGuid.GUID
 
  BufferSize = 255
  *Buffer = AllocateMemory(BufferSize)
  If *Buffer
   
    PowrProf_StringToGUID(GUID$, @TempGuid)
   
    Result = PowerReadFriendlyName(#Null, @TempGuid, #Null, #Null, *Buffer, @BufferSize)
    If Result = #MORE_DATA
      FreeMemory(*Buffer)
      *Buffer = AllocateMemory(BufferSize)
      If *Buffer
        Result = PowerReadFriendlyName(#Null, @TempGuid, #Null, #Null, *Buffer, @BufferSize)
      EndIf
    EndIf
   
    If Result = #SUCCESS
      Name$ = PeekS(*Buffer)
    EndIf
   
    FreeMemory(*Buffer)
  EndIf
 
  ProcedureReturn Name$
 
EndProcedure




Procedure.i SetPlanName(Guid$, Name$)
 
  Protected Result.i, TempGuid.GUID
 
 
  PowrProf_StringToGUID(Guid$, @TempGuid)
 
  Result = PowerWriteFriendlyName(#Null, @TempGuid, #Null, #Null, Name$, StringByteLength(Name$, #PB_Unicode) + 2)
 
  If Result = #SUCCESS
    Result = #True
  Else
    Result = #False
  EndIf
 
  ProcedureReturn Result
 
EndProcedure




Procedure.s GetPlanDescription(Guid$)
 
  Protected BufferSize.l, *Buffer, Result.i, TempGuid.GUID, Description$
 
 
  BufferSize = 255
  *Buffer = AllocateMemory(BufferSize)
  If *Buffer
   
    PowrProf_StringToGUID(GUID$, @TempGuid)
   
    Result = PowerReadDescription(#Null, @TempGuid, #Null, #Null, *Buffer, @BufferSize)
   
    If Result = #MORE_DATA
      FreeMemory(*Buffer)
      *Buffer = AllocateMemory(BufferSize)
      If *Buffer
        Result = PowerReadDescription(#Null, @TempGuid, #Null, #Null, *Buffer, @BufferSize)
      EndIf
    EndIf
   
    If Result = #SUCCESS
      Description$ = PeekS(*Buffer)
    EndIf
   
    FreeMemory(*Buffer)
  EndIf
 
  ProcedureReturn Description$
 
EndProcedure




Procedure.i SetPlanDescription(Guid$, Description$)
 
  Protected Result.i, TempGuid.GUID
 
 
  PowrProf_StringToGUID(Guid$, @TempGuid)
 
  Result = PowerWriteDescription(#Null, @TempGuid, #Null, #Null, Description$, StringByteLength(Description$, #PB_Unicode) + 2)
 
  If Result = #SUCCESS
    Result = #True
  Else
    Result = #False
  EndIf
 
  ProcedureReturn Result
 
EndProcedure




Procedure.s DuplicatePlan(SourceGuid$, TargetGuid$="")
 
  Protected Result.i, SourceGuid.GUID, *TargetGuid.GUID
 
 
  PowrProf_StringToGUID(SourceGuid$, @SourceGuid)
 
  *TargetGuid = AllocateMemory(SizeOf(GUID))
  If TargetGuid$ = ""
    UuidCreate_(*TargetGuid)
  Else
    PowrProf_StringToGUID(TargetGuid$, *TargetGuid)
  EndIf
 
  Result = PowerDuplicateScheme(#Null, @SourceGuid, @*TargetGuid)
 
  If Result <> #SUCCESS
    TargetGuid$ = ""
  Else
    TargetGuid$ = PowrProf_GUIDToString(*TargetGuid)
  EndIf
 
  ProcedureReturn TargetGuid$
 
EndProcedure




Procedure.i ListPlans(List PlanList.s())
 
  Protected Index.l, *Buffer, BufferSize.l, AccessFlags.l, Result.i
 
 
  BufferSize = 16
  *Buffer = AllocateMemory(BufferSize)
  If *Buffer
   
    ClearList(PlanList())
   
    AccessFlags = #ACCESS_SCHEME
   
    Repeat
      Result = PowerEnumerate(#Null, #Null, #Null, AccessFlags, Index, *Buffer, @BufferSize)     
     
      If Result = #SUCCESS
        AddElement(PlanList())
        PlanList() = PowrProf_GUIDToString(*Buffer)
      EndIf
     
      Index + 1
     
    Until Result = #NO_MORE_ITEMS
   
    FreeMemory(*Buffer)
  EndIf
 
  ProcedureReturn ListSize(PlanList())
 
EndProcedure




Procedure.i PlanExists(Guid$)
 
  Protected NewList PlanList.s(), Result.i
 
 
  ListPlans(PlanList())
  ForEach PlanList()
    If PlanList() = Guid$
      Result = #True
      Break
    EndIf
  Next
 
  ProcedureReturn Result
 
EndProcedure




Procedure.i DeletePlan(Guid$)
 
  Protected Result.i, TempGuid.GUID
 
 
  PowrProf_StringToGUID(Guid$, @TempGuid)
 
  Result = PowerDeleteScheme(#Null, @TempGuid)
 
  If Result = #SUCCESS
    Result = #True
  Else
    Result = #False
  EndIf
 
  ProcedureReturn Result
 
EndProcedure




Procedure.i DeletePlanIfExists(Guid$)
 
  Protected Result.i
 
 
  If PlanExists(Guid$)
    Result = DeletePlan(Guid$)
  EndIf
 
  ProcedureReturn Result
 
EndProcedure




Procedure.i GetPlanSetting(Guid$, subgroup.l, setting.l, powerMode.l)
 
  Protected Value.l, Result.i, TempGuid.GUID
 
 
  If powerMode = #AC Or powerMode = #DC
   
    If FindMapElement(Setting(), Str(Setting))
      If FindMapElement(SettingSubgroup(), Str(subgroup))
       
        PowrProf_StringToGUID(Guid$, @TempGuid)
       
        If powerMode & #AC
          Result = PowerReadACValueIndex(#Null, @TempGuid, SettingSubgroup(), Setting(), @Value)
        ElseIf powerMode & #DC
          Result = PowerReadDCValueIndex(#Null, @TempGuid, SettingSubgroup(), Setting(), @Value)
        EndIf
       
        If Result <> #SUCCESS
          Value = -1
        EndIf
       
      EndIf
    EndIf
   
  EndIf
 
  ProcedureReturn Value
 
EndProcedure




Procedure.i SetPlanSetting(Guid$, Subgroup.l, Setting.l, PowerMode.l, Value.l)
 
  Protected Result.i, TempGuid.GUID
 
 
  If powerMode = #AC Or powerMode = #DC
   
    If FindMapElement(Setting(), Str(Setting))
      If FindMapElement(SettingSubgroup(), Str(subgroup))
       
        PowrProf_StringToGUID(Guid$, @TempGuid)
       
        If powerMode & #AC
          Result = PowerWriteACValueIndex(#Null, @TempGuid, SettingSubgroup(), Setting(), Value)
        ElseIf powerMode & #DC
          Result = PowerWriteDCValueIndex(#Null, @TempGuid, SettingSubgroup(), Setting(), Value)
        EndIf
       
        If Result = #SUCCESS
          Result = #True
        Else
          Result = #False
        EndIf
       
      EndIf
    EndIf
   
  EndIf
 
  ProcedureReturn Result
 
EndProcedure






;-Demo
CompilerIf #PB_Compiler_IsMainFile
 
  Define ActiveGUID$, Line$, Value.l, NewGuid$
  NewList PlanList.s()
 
  PowrProf_Init()
 
  ActiveGUID$ = GetActivePlan()
 
  ListPlans(PlanList())
  ForEach PlanList()
    Line$ = PlanList() + " "
    Line$ + "(" + GetPlanName(PlanList()) + ")"
    If PlanList() = ActiveGUID$
      Line$ + " *"
    EndIf
    Debug Line$
    Debug GetPlanDescription(PlanList())
  Next
 
  Debug PlanExists(ActiveGUID$)
  Debug PlanExists("")
 
  Debug ""
 
  Value = GetPlanSetting(ActiveGUID$, #VIDEO_SUBGROUP, #VIDEOIDLE, #AC)
  Debug Value
  Debug GetPlanSetting(ActiveGUID$, #VIDEO_SUBGROUP, #VIDEOIDLE, #DC)
 
  Debug SetPlanSetting(ActiveGUID$, #VIDEO_SUBGROUP, #VIDEOIDLE, #AC, 666)
  Debug GetPlanSetting(ActiveGUID$, #VIDEO_SUBGROUP, #VIDEOIDLE, #AC)
  Debug SetPlanSetting(ActiveGUID$, #VIDEO_SUBGROUP, #VIDEOIDLE, #AC, Value)
  Debug GetPlanSetting(ActiveGUID$, #VIDEO_SUBGROUP, #VIDEOIDLE, #AC)
 
  Debug ""
 
  NewGuid$ = DuplicatePlan(ActiveGUID$)
  If NewGuid$ <> ""
   
    ListPlans(PlanList())
    ForEach PlanList()
      Line$ = PlanList()
      Debug Line$
    Next
   
    Debug ""
    Debug GetPlanName(NewGuid$)
    SetPlanName(NewGuid$, "Testplan")
    Debug GetPlanName(NewGuid$)
   
    Debug ""
    Debug GetPlanDescription(NewGuid$)
    SetPlanDescription(NewGuid$, "Test description")
    Debug GetPlanDescription(NewGuid$)
   
    DeletePlan(NewGuid$)
   
    Debug ""
   
    ListPlans(PlanList())
    ForEach PlanList()
      Line$ = PlanList()
      Debug Line$
    Next
   
  EndIf
 
  PowrProf_Close()
 
CompilerEndIf


Top
 Profile  
Reply with quote  
 Post subject: Re: Windows Powrprof API
PostPosted: Tue Jun 25, 2019 12:57 am 
Offline
Addict
Addict
User avatar

Joined: Mon Oct 26, 2015 2:55 am
Posts: 908
Location: UA
Cool, looks like complete API, unlike my previous example

_________________
Dreamness

Like a copyleft notify: all the source code created by me and posted on Purebasic official forums is free to use and modification in all possible (and several impossible) ways for anyone, without asking my permission


Top
 Profile  
Reply with quote  
 Post subject: Re: Windows Powrprof API
PostPosted: Wed Jun 26, 2019 2:14 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4528
Location: Lyon - France
I don't really understand :oops:
But apparently that works on W7 X86 :D
Quote:
381B4222-F694-41F0-9685-FF5BB260DF2E (Usage normal)
Équilibre automatiquement les performances et la consommation d’énergie sur les matériels compatibles.
8C5E7FDA-E8BF-4A96-9A85-A6E23A8C635C (Performances élevées)
Privilégie les performances, mais peut consommer davantage d’énergie.
A1841308-3541-4FAB-BC81-F71556F20B4A (Économie d’énergie)
Économise de l’énergie en réduisant les performances de l’ordinateur dans la mesure du possible.
DB310065-829B-4671-9647-2261C00E86EF (Customized Peak (ConfigMgr) STD Portable) *
Description for Customized Peak (ConfigMgr) STD Portable
1
0

7200
600
1
666
1
7200

381B4222-F694-41F0-9685-FF5BB260DF2E
8C5E7FDA-E8BF-4A96-9A85-A6E23A8C635C
A1841308-3541-4FAB-BC81-F71556F20B4A
AB5D3B19-33C3-4155-9CFF-1176A4A5DCD3
DB310065-829B-4671-9647-2261C00E86EF

Customized Peak (ConfigMgr) STD Portable
Testplan

Description for Customized Peak (ConfigMgr) STD Portable
Test description

381B4222-F694-41F0-9685-FF5BB260DF2E
8C5E7FDA-E8BF-4A96-9A85-A6E23A8C635C
A1841308-3541-4FAB-BC81-F71556F20B4A
DB310065-829B-4671-9647-2261C00E86EF
Thanks for sharing 8)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye