I've been searching and searching for any info within the system registry for these two dialog settings. Any help would be greatly appreciated if you know where I can find these settings using Regedit, and hopefully they're global.
I'm trying to write a program that sets the "Turn off monitor" setting to "Never", change the "When I press the power button on my computer" to "Do nothing", and remove the checkmark from "Prompt for password when computer resumes from standby".
(http://img691.imageshack.us/img691/6216/poweroptionsproperties.png) (http://img691.imageshack.us/i/poweroptionsproperties.png/)
(http://img25.imageshack.us/img25/7553/poweroptionspropertiesp.png) (http://img25.imageshack.us/i/poweroptionspropertiesp.png/)
I work for a company that is replacing computers by the dozens at multiple worldwide locations and every step I can take to shorten the time helps tremendously. These settings are having to be changed manually, along with many others, and I'd rather run one program to make it happen all at once. I also need to turn off the screensaver.
Many thanks,
-Shooter
Is there anything useful here:
http://msdn.microsoft.com/en-us/library/bb968807(VS.85).aspx
There is a PowerButton member here:
http://msdn.microsoft.com/en-us/library/aa373225(VS.85).aspx
Michael,
I think I'd have to have a program running all the time to utilize those. What I'm looking for is a means to change those settings permanently so that a person has to press the power button for 10+ seconds in order to turn off the computer... harsh, I know, but since they placed the power button on these computers (Dell ELO model 15A1) in such an easy-to-hit-accidentally location, I need to disable it.
-Shooter
Quote from: Shooter on February 01, 2011, 03:02:43 PM
Michael,
I think I'd have to have a program running all the time to utilize those. What I'm looking for is a means to change those settings permanently so that a person has to press the power button for 10+ seconds in order to turn off the computer... harsh, I know, but since they placed the power button on these computers (Dell ELO model 15A1) in such an easy-to-hit-accidentally location, I need to disable it.
-Shooter
The power policy API does not require that the program calling it be running all the time, it changes things on the system level either for a user policy or a global machine policy.
Edgar,
I've been looking over those links that Michael gave me... I must be daft or something because I'm not finding anything that fits my specific need, well, at least nothing is popping out saying, "Ooh, ooh. Pick me! Pick me!" lol
Do you know of a specific function that disables the power button?
-Shooter
One idea would be to velcro something like a bottle cap and put it over the power button.
:lol or train them by giving a little electric shock every time they touch it
You could use the old RegMon tool to monitor the registry access. It will give at least some hints.
To get rid of most of the other traffic, which confuses and disturbs only, close all other apps, including windows explorer, then do the change. I tried it and got:
14.34620881 RUNDLL32.EXE:1928 CreateKey HKCU\Control Panel\PowerCfg\GlobalPowerPolicy SUCCESS Key: 0xE144DA68
14.34622920 RUNDLL32.EXE:1928 CreateKey HKLM\Software\Microsoft\Windows\CurrentVersion\Controls Folder\PowerCfg\GlobalPowerPolicy SUCCESS Key: 0xE264C5F0
14.34661137 RUNDLL32.EXE:1928 SetValue HKCU\Control Panel\PowerCfg\GlobalPowerPolicy\Policies SUCCESS 01 00 00 00 00 00 00 00 ...
14.34663121 RUNDLL32.EXE:1928 SetValue HKLM\Software\Microsoft\Windows\CurrentVersion\Controls Folder\PowerCfg\GlobalPowerPolicy\Policies SUCCESS 01 00 00 00 01 00 00 00 ...
14.34670915 RUNDLL32.EXE:1928 QueryValue HKCU\Control Panel\PowerCfg\CurrentPowerPolicy SUCCESS "0"
14.34682816 RUNDLL32.EXE:1928 CreateKey HKCU\Control Panel\PowerCfg\PowerPolicies\0 SUCCESS Key: 0xE264C5F0
14.34684771 RUNDLL32.EXE:1928 CreateKey HKLM\Software\Microsoft\Windows\CurrentVersion\Controls Folder\PowerCfg\PowerPolicies\0 SUCCESS Key: 0xE268D3D8
14.34688822 RUNDLL32.EXE:1928 QueryValue HKCU\Control Panel\PowerCfg\PowerPolicies\0\Policies SUCCESS 01 00 00 00 00 00 00 00 ...
14.34690415 RUNDLL32.EXE:1928 QueryValue HKLM\Software\Microsoft\Windows\CurrentVersion\Controls Folder\PowerCfg\PowerPolicies\0\Policies SUCCESS 01 00 00 00 02 00 00 00 ...
14.34696756 RUNDLL32.EXE:1928 CreateKey HKLM\Software\Microsoft\Windows\CurrentVersion\Controls Folder\PowerCfg\ProcessorPolicies\0 SUCCESS Key: 0xE1160430
14.34697957 RUNDLL32.EXE:1928 QueryValue HKLM\Software\Microsoft\Windows\CurrentVersion\Controls Folder\PowerCfg\ProcessorPolicies\0\Policies BUFOVRFLOW
14.34699522 RUNDLL32.EXE:1928 QueryValue HKLM\Software\Microsoft\Windows\CurrentVersion\Controls Folder\PowerCfg\ProcessorPolicies\0\Policies SUCCESS 01 00 00 00 01 00 00 00 ...
14.34710696 RUNDLL32.EXE:1928 CreateKey HKCU\Control Panel\PowerCfg\PowerPolicies\0 SUCCESS Key: 0xE264C5F0
14.34712512 RUNDLL32.EXE:1928 CreateKey HKLM\Software\Microsoft\Windows\CurrentVersion\Controls Folder\PowerCfg\PowerPolicies\0 SUCCESS Key: 0xE1160430
14.34716396 RUNDLL32.EXE:1928 SetValue HKCU\Control Panel\PowerCfg\PowerPolicies\0\Policies SUCCESS 01 00 00 00 00 00 00 00 ...
14.34717876 RUNDLL32.EXE:1928 SetValue HKLM\Software\Microsoft\Windows\CurrentVersion\Controls Folder\PowerCfg\PowerPolicies\0\Policies SUCCESS 01 00 00 00 02 00 00 00 ...
14.34727989 RUNDLL32.EXE:1928 CreateKey HKCU\Control Panel\PowerCfg\GlobalPowerPolicy SUCCESS Key: 0xE1160430
14.34729917 RUNDLL32.EXE:1928 CreateKey HKLM\Software\Microsoft\Windows\CurrentVersion\Controls Folder\PowerCfg\GlobalPowerPolicy SUCCESS Key: 0xE268D3D8
14.34733940 RUNDLL32.EXE:1928 SetValue HKCU\Control Panel\PowerCfg\GlobalPowerPolicy\Policies SUCCESS 01 00 00 00 00 00 00 00 ...
14.34735560 RUNDLL32.EXE:1928 SetValue HKLM\Software\Microsoft\Windows\CurrentVersion\Controls Folder\PowerCfg\GlobalPowerPolicy\Policies SUCCESS 01 00 00 00 01 00 00 00 ...
Quote from: oex on February 01, 2011, 05:44:09 PM
:lol or train them by giving a little electric shock every time they touch it
Like a fence charger? :U
Hi shooter,
I doubt that you will find one worded exactly the way you expect. Usually with APIs such as this one there is a generic function that is switched by a GUID that identifies the parameter you are setting. It is for the most part a complicated interface to work with but allows for a large amount of flexibility and expansion with fewer exported API functions. You will find interfaces like this for functions that involve a very large number of different parameters and device specific settings, exporting a particular API for each or defining a massive header and innumerable constants is impractical in these cases.
Quote from: Shooter on February 01, 2011, 05:29:56 PM
Do you know of a specific function that disables the power button?
-Shooter
The BIOS? would be easier :-)
Actually the links posted loo to do what you want.. look into WriteGlobalPwrPolicy, GLOBAL_USER_POWER_POLICY
Looks like some good info here.
http://us.generation-nt.com/answer/cannot-set-power-button-option-using-power-management-api-windo-help-27669072.html
A quick look at the link MichaelW gave you shows the WriteGlobalPwrPolicy (http://msdn.microsoft.com/en-us/library/aa373250%28v=VS.85%29.aspx) which appears to do most if not all of what you want. Magnum has posted a rudimentary example of how to call it so you should be able to figure it out from there. For the screen saver that's just SystemParametersInfo (http://msdn.microsoft.com/en-us/library/ms724947%28v=vs.85%29.aspx) there are plenty of examples of that.
Alrighty then, is there a library to include that holds these functions? PowrProf.lib doesn't appear to be a valid library.
-Shooter