A much shortened code to only get that value can be seen here:
Dim g As IntPtr, sz As UInteger = 4, data As IntPtr = IntPtr.Zero
PowerGetActiveScheme(IntPtr.Zero, g)
PowerReadACValue(IntPtr.Zero, g, GUID_VIDEO_SUBGROUP, GUID_VIDEOIDLE, 0, data, sz)
LocalFree(g)
Debug.WriteLine(CUInt(data) / 60)
It uses these definitions
Public Declare Function PowerGetActiveScheme Lib "powrprof.dll" (UserRootPowerKey As IntPtr, ByRef ActivePolicyGuid As IntPtr) As Integer
Public Declare Function LocalFree Lib "kernel32.dll" (hMem As IntPtr) As IntPtr
Public GUID_VIDEO_SUBGROUP As New Guid("7516b95f-f776-4464-8c53-06167f40cc99")
Public GUID_VIDEOIDLE As New Guid("3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e")
Public Declare Function PowerReadACValue Lib "powrprof.dll" (RootPowerKey As IntPtr, SchemeGuid As IntPtr,
ByRef SubGroupOfPowerSettingsGuid As Guid, ByRef PowerSettingGuid As Guid,
ByRef Type As UInteger, ByRef Buffer As IntPtr, ByRef BufferSize As UInteger) As Integer ' same for PowerReadDCValue
You can perhaps get better understanding of the layout with the powercfg command line tool.
this seems to get the monitor off time not the sleep time of the pc. do i need to change those video group to sleep group?PublicPublic GUID_SLEEP_SUBGROUP AsNew Guid("238C9FA8-0AAD-41ED-83F4-97BE242C8F20")
But i cant seem to see an idle time under this subgroup that match my setting in the registery
the closest description would be System idle timeout before the system enters a low power standby state. 29f6c1db-86da-48c5-9fdb-f2b67b1f44da
but the AcSettingIndex show 1800 but my sleep time is 60 min not 30 min
Idle timeout before the system returns to a low power sleep state after waking unattended.
7bc4a2f9-d8fc-4469-b07b-33eb785aaca0
This one show 120
Yes, and the STANDBYIDLE guid is 29f6c1db-86da-48c5-9fdb-f2b67b1f44da. I get correct values for this and 0 for 'never'.
You can also see this if you do a "powercfg -q {active scheme guid} {GUID_SLEEP_SUBGROUP}", that outputs the seconds value as hex though, so you have to convert.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.