Advertisement

02.12.2008 at 07:17PM PST, ID: 23158586
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

Trying to create standalone executable in C++ with VS2005 to set Power Management properties on Windows 2000, XP, and Vista.

Asked by steverey443 in Microsoft Visual C++.Net, C++ Programming Language, Visual Studio

Tags: ,

I'm trying to create standalone executable in C++ with VS2005to set Power Management properties on Windows 2000, XP, and Vista.

I got some code from here:
http://softwarecommunity.intel.com/articles/eng/2667.htm

But it uses SetCurrentPowerPolicies which is an invalid identifier.  Current code below.

I don't need to use any of this code but I do need this to not be dependent on .NET or any other software that doesn't come with 2000, XP, and Vista by default.

Totally new to C++.  I thinks this would have been done a long time ago if I could use .NET.

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
// IdleTime.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h";
#include "powrprof.h"
 
 
using namespace std;
 
 
int _tmain(int argc, _TCHAR* argv[])
{
    double tickCount;
double idleCount;
LASTINPUTINFO lpi;
lpi.cbSize = sizeof(LASTINPUTINFO);
 
if (!GetLastInputInfo(&lpi))
{
// failed, use GetLastError to get error code
}
 
// lpi.dwTime now holds the tick count when last input was made
 
//cout << lpi.dwTime << endl;
tickCount = GetTickCount();
idleCount = ( tickCount - lpi.dwTime );
cout << idleCount / 1000 << endl;
 
//GLOBAL_POWER_POLICY CurrentGP;
//POWER_POLICY CurrentPP;
//UINT id;
//GetActivePwrScheme(&id);                          //capture id of current scheme
//GetCurrentPowerPolicies(&CurrentGP,&CurrentPP);   //get active policies
////if(CanUserWritePwrScheme() == FALSE) {cout << "no";};
 
GLOBAL_POWER_POLICY CurrentGP;
POWER_POLICY CurrentPP;
ULONG savVidAC,savVidDC;
UINT id;
UINT ssav;
 
GetActivePwrScheme(&id);                          //capture id of current scheme
GetCurrentPowerPolicies(&CurrentGP,&CurrentPP);   //get active policies
savVidAC = CurrentPP.user.VideoTimeoutAc;         //save current values
savVidDC = CurrentPP.user.VideoTimeoutDc;
CurrentPP.user.VideoTimeoutAc = 15;                //disallow display shutoff
CurrentPP.user.VideoTimeoutDc = 14;
//set new values.  Not sure how to save values
SetCurrentPowerPolicies(id,CurrentGP,&CurrentPP); //set new values
// get error:  Error	1	error C3861: 'SetCurrentPowerPolicies': identifier not found	
//      c:\Programming\PowerManagement\SetPMSettingsCPlusPlus\IdleTime\IdleTime.cpp	50	
 
//SystemParametersInfo (SPI_GETSCREENSAVETIMEOUT,0,&ssav,0);  //save current value
//SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT,0,NULL,0);    //turn off screen saver
 
	return 0;
}
[+][-]02.12.2008 at 07:52PM PST, ID: 20881508

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.13.2008 at 12:25PM PST, ID: 20887797

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.13.2008 at 12:28PM PST, ID: 20887830

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.13.2008 at 01:29PM PST, ID: 20888413

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.13.2008 at 01:38PM PST, ID: 20888505

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C++.Net, C++ Programming Language, Visual Studio
Tags: C++, Windows Executable
Sign Up Now!
Solution Provided By: jkr
Participating Experts: 1
Solution Grade: A
 
 
[+][-]02.13.2008 at 02:16PM PST, ID: 20888932

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.13.2008 at 02:20PM PST, ID: 20888960

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.13.2008 at 03:18PM PST, ID: 20889456

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.13.2008 at 04:03PM PST, ID: 20889739

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628