Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 132287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:14:19+00:00 2026-05-11T06:14:19+00:00

In an application I wrote a few years back I use function SystemParametersInfo with

  • 0

In an application I wrote a few years back I use function SystemParametersInfo with SPI_GETPOWEROFFTIMEOUT to get the timeout for monitor off. On Vista this doesn’t work anymore.

So I decided to make this work on Vista, but after a few hours I feel like I’m no closer to a solution.

Most of the functions I am going to mention are described on http://msdn.microsoft.com/en-us/library/aa373163(VS.85).aspx

To my understanding I should: 1. use function PowerGetActiveScheme, to get current scheme 2. use PowerEnumerate with GUID_VIDEO_SUBGROUP 3. use PowerReadACValue (or DC value) to get the value.

Is this right? Seems like a lot of work to get to one setting. If this is the correct way, there is one thing I don’t understand. On my system PowerEnumerate returns 3 keys. How do I know which one is for Monitor timeout?

Here is my code so far. I’m having trouble with PowerReadACValue, I probably didn’t define or use it properly.

class Program {     [DllImport('powrprof.dll')]     static extern UInt32 PowerGetActiveScheme(IntPtr UserRootPowerKey, ref IntPtr ActivePolicyGuid);      [DllImport('powrprof.dll')]     static extern uint PowerEnumerate(                 IntPtr RootPowerKey,                 IntPtr SchemeGuid,                 Guid SubGroupOfPowerSettingGuid,                 UInt32 AcessFlags,                 UInt32 Index,                 ref Guid Buffer,                 ref UInt32 BufferSize);      [DllImport('powrprof.dll')]     static extern uint PowerReadACValue(                 IntPtr RootPowerKey,                 IntPtr SchemeGuid,                 IntPtr SubGroupOfPowerSettingGuid,                 Guid PowerSettingGuid,                 ref IntPtr Type,                 ref IntPtr Buffer,                 ref UInt32 BufferSize);      static void Main(string[] args)     {         IntPtr activeGuidPtr = IntPtr.Zero;         uint res = PowerGetActiveScheme(IntPtr.Zero, ref activeGuidPtr);         if (res == 0)         {             Guid VideoSettingGuid = new Guid();             UInt32 index = 0;             UInt32 BufferSize = (UInt32)Marshal.SizeOf(typeof(Guid));             while (0 == PowerEnumerate(                 IntPtr.Zero, activeGuidPtr, new Guid('7516b95f-f776-4464-8c53-06167f40cc99'), 18, index, ref VideoSettingGuid, ref BufferSize))             {                 Console.Write(VideoSettingGuid.ToString() + ': ');                  UInt32 size = 1024;                 IntPtr temp = Marshal.AllocHGlobal(1024);                 IntPtr type = IntPtr.Zero;                  PowerReadACValue(IntPtr.Zero, activeGuidPtr, IntPtr.Zero, VideoSettingGuid, ref type, ref temp, ref size);                  Console.Write(Marshal.PtrToStringUni(temp));                 Marshal.FreeHGlobal(temp);                 index++;             }         }     } } 

I also tried using GetActivePwrScheme and then ReadPwrScheme, but it doesn’t seem to work either. GetActivePwrScheme always returns 0, even if I switch power schemes. I also tried running ReadPwrScheme with incremental values (1,2,3). I got to 5 or 6 but it never returned the correct number for the value I set for monitor timeout in control panel.

I hope I have this totally wrong and there is a much easier way of doing this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:14:20+00:00Added an answer on May 11, 2026 at 6:14 am

    I finally did have some luck and found a function which works on both XP and Vista – GetCurrentPowerPolicies. It is very simple to call and returns a lot of the current settings including the setting I wanted VideoTimeoutAc and VideoTimeoutDc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 88k
  • Answers 88k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer issubclass only works for instances, not class objects themselves. It… May 11, 2026 at 5:45 pm
  • Editorial Team
    Editorial Team added an answer Windows CE Relationship to Windows Mobile, Pocket PC, and SmartPhone May 11, 2026 at 5:45 pm
  • Editorial Team
    Editorial Team added an answer If you want to make Cross-Domain calls with jQuery you'll… May 11, 2026 at 5:45 pm

Related Questions

Our application is interfacing with a lot of web services these days. We have
Almost 5 years ago Joel Spolsky wrote this article, The Absolute Minimum Every Software
Today I was thinking about a Python project I wrote about a year back
Our product earned bad reputation in terms of performance. Well, it's a big enterprise

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.