AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Überprüfen ob PC über Standby verfügt
Thema durchsuchen
Ansicht
Themen-Optionen

Überprüfen ob PC über Standby verfügt

Ein Thema von schwa226 · begonnen am 25. Aug 2009 · letzter Beitrag vom 25. Aug 2009
Antwort Antwort
schwa226

Registriert seit: 4. Apr 2008
400 Beiträge
 
#1

Überprüfen ob PC über Standby verfügt

  Alt 25. Aug 2009, 16:13
Hi,

ich habe dazu nichts gefunden.

Kann man einen PC überprüfen öb er über Standby Modus verfügt?

Bei meinem PC gibt's ja Standby, bei meinem VirtualPC jedoch nicht.
Wenn man das rausfinden kann, kann ich meinen Bring-Den-PC-In-Standby Mode deaktivieren.

Gibt's da was dazu?
Delphi 2010, Update 4 & 5
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.540 Beiträge
 
Delphi 11 Alexandria
 
#2

Re: Überprüfen ob PC über Standby verfügt

  Alt 25. Aug 2009, 16:26
Dies hier scheint eine gute erste Anlaufstelle zu sein: http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
schwa226

Registriert seit: 4. Apr 2008
400 Beiträge
 
#3

Re: Überprüfen ob PC über Standby verfügt

  Alt 25. Aug 2009, 16:42
Danke!

Hab's gefunden:

Delphi-Quellcode:
unit PowrProf;

interface

uses
   Windows, Messages;

const
   POWER_ACTION_CRITICAL = 1; //Forces a critical suspension.
   POWER_ACTION_DISABLE_WAKES = 2; //Disables all wake events.
   POWER_ACTION_LIGHTEST_FIRST = 4; //Uses the first lightest available sleep state.
   POWER_ACTION_LOCK_CONSOLE = 8 ; //Requires entry of the system password upon resume from one of the system standby states.
   POWER_ACTION_OVERRIDE_APPS = 16; //Ignores applications that do not respond to the PBT_APMQUERYSUSPEND event broadcast in the WM_POWERBROADCAST message.
   POWER_ACTION_QUERY_ALLOWED = 32; //Broadcasts a PBT_APMQUERYSUSPEND event to each application to request permission to suspend operation.
   POWER_ACTION_UI_ALLOWED = 64;

   POWER_FORCE_TRIGGER_RESET = 1; //Clears a user power button press.
   POWER_LEVEL_USER_NOTIFY_EXEC = 2; //Specifies a program to be executed.
   POWER_LEVEL_USER_NOTIFY_SOUND = 4; //User notified using sound.
   POWER_LEVEL_USER_NOTIFY_TEXT = 8; //User notified using the UI.
   POWER_USER_NOTIFY_BUTTON = 16; //Indicates that the power action is in response to a user power button press.
   POWER_USER_NOTIFY_SHUTDOWN = 32;

type

// =================== ENUMERATIONS ===================

   SYSTEM_POWER_STATE =(PowerSystemUnspecified, PowerSystemWorking, PowerSystemSleeping1,
      PowerSystemSleeping2, PowerSystemSleeping3, PowerSystemHibernate,
      PowerSystemShutdown, PowerSystemMaximum);

   POWER_ACTION = (PowerActionNone, PowerActionReserved, PowerActionSleep, PowerActionHibernate,
      PowerActionShutdown, PowerActionShutdownReset, PowerActionShutdownOff, PowerActionWarmEject);

   POWER_INFORMATION_LEVEL = (AdministratorPowerPolicy, LastSleepTime, LastWakeTime, ProcessorInformation, ProcessorPowerPolicyAc,
      ProcessorPowerPolicyCurrent, ProcessorPowerPolicyDc, SystemBatteryState, SystemExecutionState, SystemPowerCapabilities,
      SystemPowerInformation, SystemPowerPolicyAc, SystemPowerPolicyCurrent, SystemPowerPolicyDc, SystemReserveHiberFile,
      VerifyProcessorPowerPolicyAc, VerifyProcessorPowerPolicyDc, VerifySystemPolicyAc, VerifySystemPolicyDc);

// =================== STRUCTURES ===================

   POWER_ACTION_POLICY = record
      Action: POWER_ACTION;
      Flags: ULONG;
      EventCode: ULONG;
   end;
   PPOWER_ACTION_POLICY = ^POWER_ACTION_POLICY;

   SYSTEM_POWER_LEVEL = record
      Enable: boolean;
      Spare: array[0..2] of UCHAR;
      BatteryLevel: ULONG;
      PowerPolicy: POWER_ACTION_POLICY;
      MinSystemState: SYSTEM_POWER_STATE;
   end;
   PSYSTEM_POWER_LEVEL = ^SYSTEM_POWER_LEVEL;

   BATTERY_REPORTING_SCALE = record
      Granularity: ULONG;
      Capacity: ULONG;
   end;
   PBATTERY_REPORTING_SCALE = ^BATTERY_REPORTING_SCALE;

   SYSTEM_POWER_CAPABILITIES = record
      PowerButtonPresent: boolean;
      SleepButtonPresent: boolean;
      LidPresent: boolean;
      SystemS1: boolean;
      SystemS2: boolean;
      SystemS3: boolean;
      SystemS4: boolean;
      SystemS5: boolean;
      HiberFilePresent: boolean;
      FullWake: boolean;
      VideoDimPresent: boolean;
      ApmPresent: boolean;
      UpsPresent: boolean;
      ThermalControl: boolean;
      ProcessorThrottle: boolean;
      ProcessorMinThrottle: UCHAR;
      ProcessorMaxThrottle: UCHAR;
      spare2: array[0..3] of UCHAR;
      DiskSpinDown: boolean;
      spare3: array[0..7] of UCHAR;
      SystemBatteriesPresent: boolean;
      BatteriesAreShortTerm: boolean;
      BatteryScale: array[0..2] of BATTERY_REPORTING_SCALE;
      AcOnLineWake: SYSTEM_POWER_STATE;
      SoftLidWake: SYSTEM_POWER_STATE;
      RtcWake: SYSTEM_POWER_STATE;
      MinDeviceWakeState: SYSTEM_POWER_STATE;
      DefaultLowLatencyWake: SYSTEM_POWER_STATE;
   end;
   PSYSTEM_POWER_CAPABILITIES = ^SYSTEM_POWER_CAPABILITIES;

   USER_POWER_POLICY = record
      Revision: ULONG;
      IdleAc: POWER_ACTION_POLICY;
      IdleDc: POWER_ACTION_POLICY;
      IdleTimeoutAc: ULONG;
      IdleTimeoutDc: ULONG;
      IdleSensitivityAc: UCHAR;
      IdleSensitivityDc: UCHAR;
      ThrottlePolicyAc: UCHAR;
      ThrottlePolicyDc: UCHAR;
      MaxSleepAc: SYSTEM_POWER_STATE;
      MaxSleepDc: SYSTEM_POWER_STATE;
      Reserved: array[0..1] of ULONG;
      VideoTimeoutAc: ULONG;
      VideoTimeoutDc: ULONG;
      SpindownTimeoutAc: ULONG;
      SpindownTimeoutDc: ULONG;
      OptimizeForPowerAc: boolean;
      OptimizeForPowerDc: boolean;
      FanThrottleToleranceAc: UCHAR;
      FanThrottleToleranceDc: UCHAR;
      ForcedThrottleAc: UCHAR;
      ForcedThrottleDc: UCHAR;
   end;
   PUSER_POWER_POLICY = USER_POWER_POLICY;

   GLOBAL_USER_POWER_POLICY = record
      Revision: ULONG;
      PowerButtonAc: POWER_ACTION_POLICY;
      PowerButtonDc: POWER_ACTION_POLICY;
      SleepButtonAc: POWER_ACTION_POLICY;
      SleepButtonDc: POWER_ACTION_POLICY;
      LidCloseAc: POWER_ACTION_POLICY;
      LidCloseDc: POWER_ACTION_POLICY;
      DischargePolicy: array of SYSTEM_POWER_LEVEL;
      GlobalFlags: ULONG;
   end;
   PGLOBAL_USER_POWER_POLICY = ^GLOBAL_USER_POWER_POLICY;

   MACHINE_POWER_POLICY = record
      Revision: ULONG;
      MinSleepAc: SYSTEM_POWER_STATE;
      MinSleepDc: SYSTEM_POWER_STATE;
      ReducedLatencySleepAc: SYSTEM_POWER_STATE;
      ReducedLatencySleepDc: SYSTEM_POWER_STATE;
      DozeTimeoutAc: ULONG;
      DozeTimeoutDc: ULONG;
      DozeS4TimeoutAc: ULONG;
      DozeS4TimeoutDc: ULONG;
      MinThrottleAc: UCHAR;
      MinThrottleDc: UCHAR;
      pad1: array[0..1] of UCHAR;
      OverThrottledAc: POWER_ACTION_POLICY;
      OverThrottledDc: POWER_ACTION_POLICY;
   end;
   PMACHINE_POWER_POLICY = ^MACHINE_POWER_POLICY;

   GLOBAL_MACHINE_POWER_POLICY = record
      Revision: ULONG;
      LidOpenWakeAc: SYSTEM_POWER_STATE;
      LidOpenWakeDc: SYSTEM_POWER_STATE;
      BroadcastCapacityResolution: ULONG;
   end;
   PGLOBAL_MACHINE_POWER_POLICY = ^GLOBAL_MACHINE_POWER_POLICY;

   POWER_POLICY = record
      user: USER_POWER_POLICY;
      mach: MACHINE_POWER_POLICY;
   end;
   PPOWER_POLICY = ^POWER_POLICY;

   GLOBAL_POWER_POLICY = record
      user: GLOBAL_USER_POWER_POLICY;
      mach: GLOBAL_MACHINE_POWER_POLICY;
   end;
   PGLOBAL_POWER_POLICY = ^GLOBAL_POWER_POLICY;

   PWRSCHEMESENUMPROC = FARPROC;
   (*
      typedef BOOLEAN (CALLBACK* PWRSCHEMESENUMPROC)(
        UINT uiIndex,      // power scheme index
        DWORD dwName,      // size of the sName string, in bytes
        LPTSTR sName,      // name of the power scheme
        DWORD dwDesc,      // size of the sDesc string, in bytes
        LPTSTR sDesc,      // description string
        PPOWER_POLICY pp,  // receives the power policy
        LPARAM lParam      // user-defined value );
   *)


// =================== FUNCTIONS ===================

function CallNtPowerInformation(InformationLevel: POWER_INFORMATION_LEVEL;
   lpInputBuffer: Pointer;
   nInputBufferSize: ULONG;
   lpOutputBuffer: Pointer;
   nOutputBufferSize: ULONG): cardinal; stdcall;
function CanUserWritePwrScheme: boolean; stdcall;
function DeletePwrScheme(uiIndex: UINT): boolean; stdcall;
function EnumPwrSchemes(EnumPwrSchemesProc: PWRSCHEMESENUMPROC; lParam: LPARAM): boolean; stdcall;
function GetActivePwrScheme(uiIndex: PUINT): boolean; stdcall;
function GetCurrentPowerPolicies(pGlobalPowerPolicy: PGLOBAL_POWER_POLICY; pPowerPolicy: PPOWER_POLICY): boolean; stdcall;
function GetPwrCapabilities(lpSystemPowerCapabilities: PSYSTEM_POWER_CAPABILITIES): boolean; stdcall;
function GetPwrDiskSpindownRange(RangeMax: PUINT; RangeMin: PUINT): boolean; stdcall;
function IsAdminOverrideActive: boolean; stdcall;
function IsPwrHibernateAllowed: boolean; stdcall;
function IsPwrShutdownAllowed: boolean; stdcall;
function IsPwrSuspendAllowed: boolean; stdcall;
//function LoadCurrentPwrScheme: boolean; stdcall;
// 16 F 00002608 MergeLegacyPwrScheme
function ReadGlobalPwrPolicy(pGlobalPowerPolicy: PGLOBAL_POWER_POLICY): boolean; stdcall;
function ReadPwrScheme(uiID: UINT; pPowerPolicy: PPOWER_POLICY): boolean; stdcall;
function SetActivePwrScheme(uiID: UINT; lpGlobalPowerPolicy: PGLOBAL_POWER_POLICY; lpPowerPolicy: PPOWER_POLICY): boolean; stdcall;
function SetSuspendState(Hibernate: boolean; ForceCritical: boolean; DisableWakeEvents: boolean): boolean; stdcall;
// 21 14 0000279E ValidatePowerPolicies
function WriteGlobalPwrPolicy(pGlobalPowerPolicy: PGLOBAL_POWER_POLICY): boolean; stdcall;
function WritePwrScheme(uiID: UINT; lpszName: LPSTR; lpszDescription: LPSTR; pPowerPolicy: PPOWER_POLICY): boolean; stdcall;

implementation

function CallNtPowerInformation(InformationLevel: POWER_INFORMATION_LEVEL;
   lpInputBuffer: Pointer;
   nInputBufferSize: ULONG;
   lpOutputBuffer: Pointer;
   nOutputBufferSize: ULONG): cardinal; external 'powrprof.dllname 'CallNtPowerInformation';
function CanUserWritePwrScheme: boolean; external 'powrprof.dllname 'CanUserWritePwrScheme';
function DeletePwrScheme(uiIndex: UINT): boolean; external 'powrprof.dllname 'DeletePwrScheme';
function EnumPwrSchemes(EnumPwrSchemesProc: PWRSCHEMESENUMPROC; lParam: LPARAM): boolean; external 'powrprof.dllname 'EnumPwrSchemes';
function GetActivePwrScheme(uiIndex: PUINT): boolean; external 'powrprof.dllname 'GetActivePwrScheme';
function GetCurrentPowerPolicies(pGlobalPowerPolicy: PGLOBAL_POWER_POLICY; pPowerPolicy: PPOWER_POLICY): boolean; external 'powrprof.dllname 'GetCurrentPowerPolicies';
function GetPwrCapabilities(lpSystemPowerCapabilities: PSYSTEM_POWER_CAPABILITIES): boolean; external 'powrprof.dllname 'GetPwrCapabilities';
function GetPwrDiskSpindownRange(RangeMax: PUINT; RangeMin: PUINT): boolean; external 'powrprof.dllname 'GetPwrDiskSpindownRange';
function IsAdminOverrideActive: boolean; external 'powrprof.dllname 'IsAdminOverrideActive';
function IsPwrHibernateAllowed: boolean; external 'powrprof.dllname 'IsPwrHibernateAllowed';
function IsPwrShutdownAllowed: boolean; external 'powrprof.dllname 'IsPwrShutdownAllowed';
function IsPwrSuspendAllowed: boolean; external 'powrprof.dllname 'IsPwrSuspendAllowed';
//function LoadCurrentPwrScheme:boolean; external 'powrprof.dll' name 'LoadCurrentPwrScheme';
// 16 F 00002608 MergeLegacyPwrScheme
function ReadGlobalPwrPolicy(pGlobalPowerPolicy: PGLOBAL_POWER_POLICY): boolean; external 'powrprof.dllname 'ReadGlobalPwrPolicy';
function ReadPwrScheme(uiID: UINT; pPowerPolicy: PPOWER_POLICY): boolean; external 'powrprof.dllname 'ReadPwrScheme';
function SetActivePwrScheme(uiID: UINT; lpGlobalPowerPolicy: PGLOBAL_POWER_POLICY; lpPowerPolicy: PPOWER_POLICY): boolean; external 'powrprof.dllname 'SetActivePwrScheme';
function SetSuspendState(Hibernate: boolean; ForceCritical: boolean; DisableWakeEvents: boolean): boolean; external 'powrprof.dllname 'SetSuspendState';
// 21 14 0000279E ValidatePowerPolicies
function WriteGlobalPwrPolicy(pGlobalPowerPolicy: PGLOBAL_POWER_POLICY): boolean; external 'powrprof.dllname 'WriteGlobalPwrPolicy';
function WritePwrScheme(uiID: UINT; lpszName: LPSTR; lpszDescription: LPSTR; pPowerPolicy: PPOWER_POLICY): boolean; external 'powrprof.dllname 'WritePwrScheme';


end.
Delphi 2010, Update 4 & 5
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:26 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz