From: mkvaugh on
Hi,

I've been trying to create a new Power Scheme in my machine
programmatically.
My machine is a Windows XP SP2. The following is a sample code that
creates a new Power Scheme,

-------------------------------------------------------------------------------------------------------------------------
BOOLEAN CreateNewPowerPolicy( LPWSTR lpwszName )
{
UINT uiID = 9;
POWER_POLICY pwrPolicy;
POWER_POLICY defaultPwrPolicy;
BOOLEAN b = TRUE;
UINT activePwr;

ZeroMemory( &defaultPwrPolicy, sizeof( POWER_POLICY ));
if( CanUserWritePwrScheme())
{
printf( "User can write power scheme! \n" );
b = WritePwrScheme( &uiID, lpwszName, L"", &pwrPolicy );
if( !b )
{
printf( "Error while writing power scheme -> %d \n", GetLastError()
);
}
}
else
{
printf( " User cannot write power schemes! %d \n", GetLastError() );
}
printf( " Finished .. %d\n", uiID );

return b;
}
-------------------------------------------------------------------------------------------------------------------------
But everytime I try to execute this code it throws an error number -
1306, and the message is "Indicates two revision levels are
incompatible.".

Can somebody help me in solving this problem?

Mike

From: mkvaugh on
Got it!
Obtained the default power scheme and its properties using
"GetActivePwrScheme" and "ReadPwrScheme". Assigned the obtained
POWER_POLICY structure to a new one and created a new power policy
scheme using "WritePwrScheme", worked like a breeze!!

Mike

 | 
Pages: 1
Prev: generating mouse clicks
Next: WMI compiing problem