x1800+ | Bonsoir à tous ^^
Je me suis lancé cet aprem dans la réalisation d'un petit programme pour changer le PowerScheme utilisé par windows suivant l'application démarrée.
- A titre d'information, le PowerScheme représente le mode d'alimentation du pc (Toujours allumé, consomation minimale...) et est utile pour l'utilisation du Cool'n'Quiet d'AMD.
Donc , pour pouvoir lister tous les PwrScheme et leur assigner une liste d'executables, j'ai cherché un peu partout et j'en suis venu à la conclusion suivante : utiliser la dll w32 Powrprof.dll .
J'ai donc trouvé ceci sur msdn :
http://msdn.microsoft.com/library/ [...] ctions.asp
Et je me suis "amusé" a tout transformer en C# (via des structs,enum,et un delegate pour le Callback)
Mais le problème est que cette fonction ne me permet (apparament), que d'obtenir un bool, qui retourne True une fois l'énumération finie (si j'ai bien compris ).
Mais comme a chaque Callback, il prend les données du PwrScheme qu'il traite, je pense que y a moyen de recuperer ses infos (c'est ce qui m'interesse en fait)....Mais je vois pas comment faire...Je bloque...
Donc voila le code
Code :
- public enum SystemPowerState
- {
- PowerSystemUnspecified = 0,
- PowerSystemWorking =1,
- PowerSystemSleeping1 = 2,
- PowerSystemSleeping2 = 3,
- PowerSystemSleeping3 = 4,
- PowerSystemHibernate = 5,
- PowerSystemShutdown = 6,
- PowerSystemMaximum = 7
- }
- public enum PowerAction
- {
- PowerActionNone = 0,
- PowerActionReserved,
- PowerActionSleep,
- PowerActionHibernate,
- PowerActionShutdown,
- PowerActionShutdownReset,
- PowerActionShutdownOff,
- PowerActionWarmEject,
- }
- public struct PowerActionPolicy
- {
- public PowerAction Action;
- public long Flags;
- public long EventCode;
- }
- [StructLayout(LayoutKind.Sequential , CharSet = CharSet.Unicode)]
- public struct UserPowerPolicy
- {
- public long Revision;
- public PowerActionPolicy IdleAc;
- public PowerActionPolicy IdleDc;
- public long IdleTimeoutAc;
- public long IdleTimeoutDc;
- public char IdleSensitivityAc;
- public char IdleSensitivityDc;
- public char ThrottlePolicyAc;
- public char ThrottlePolicyDc;
- public SystemPowerState MaxSleepAc;
- public SystemPowerState MaxSleepDc;
- [MarshalAs(UnmanagedType.ByValTStr , SizeConst = 2)]
- public string Reserved;
- public long VideoTimeoutAc;
- public long VideoTimeoutDc;
- public long SpindownTimeoutAc;
- public long SpindownTimeoutDc;
- public bool OptimizeForPowerAc;
- public bool OptimizeForPowerDc;
- public char FanThrottleToleranceAc;
- public char FanThrottleToleranceDc;
- public char ForcedThrottleAc;
- public char ForcedThrottleDc;
- }
- [StructLayout(LayoutKind.Sequential , CharSet = CharSet.Unicode)]
- public struct MachinePowerPolicy
- {
- public long Revision;
- public SystemPowerState MinSleepAc;
- public SystemPowerState MinSleepDc;
- public SystemPowerState ReducedLatencySleepAc;
- public SystemPowerState ReducedLatencySleepDc;
- public long DozeTimeoutAc;
- public long DozeTimeoutDc;
- public long DozeS4TimeoutAc;
- public long DozeS4TimeoutDc;
- public char MinThrottleAc;
- public char MinThrottleDc;
- [MarshalAs(UnmanagedType.ByValTStr , SizeConst = 2)]
- public string pad1;
- public PowerActionPolicy OverThrottledAc;
- public PowerActionPolicy OverThrottledDc;
- }
- public struct PowerPolicy
- {
- public UserPowerPolicy user;
- public MachinePowerPolicy mach;
- }
- public delegate bool PowerSchemeEnumProc
- (
- int uiIndex ,
- int dwName ,
- [MarshalAs(UnmanagedType.LPWStr)]
- string sName ,
- int dwDesc ,
- [MarshalAs(UnmanagedType.LPWStr)]
- string sDesc ,
- PowerPolicy pp ,
- int lParam
- );
- [DllImport("Powrprof.dll" )]
- static extern bool EnumPwrSchemes(PowerSchemeEnumProc CallBack , int Params);
|
Voilà pour le petit paté de code...Ce qui me pose probleme c'est donc la suite pour pouvoir récupérer les infos de chaque PwrScheme...
Marchi à ceux qui m'aideront Et meme a ceux qui s'interesseront au probleme Et pis bonne soirée |