Partager via


IMDSPDevice::GetPowerSource

banner art

The GetPowerSource method reports whether the device is capable of running on batteries, external power, or both, and on which type of power source it is currently running. If the device is running on batteries, this method also reports the percentage of total power remaining in the batteries. This method is optional. For more information, see the second table under Implementing Service Providers.

Syntax

HRESULT GetPowerSource(
  DWORD*  pdwPowerSource,
  DWORD*  pdwPercentRemaining
);

Parameters

pdwPowerSource

[out] Pointer to a DWORD that receives a value indicating the current power source for the device. The value is one of the following flags.

Flag Description
WMDM_POWER_CAP_BATTERY The media device can run on batteries.
WMDM_POWER_CAP_EXTERNAL The media device can run on external power.
WMDM_POWER_IS_BATTERY The media device is currently running on batteries.
WMDM_POWER_IS_EXTERNAL The media device is currently running on external power.
WMDM_POWER_PERCENT_AVAILABLE The percentage of power remaining was returned in pdwPercentRemaining.

pdwPercentRemaining

[out] ** If the device is running on batteries, pdwPercentRemaining specifies a pointer to a DWORD containing the percentage of total battery power remaining.

Return Values

The method returns an HRESULT. All the interface methods in Windows Media Device Manager and service provider can return any of the following classes of error codes:

  • Standard COM error codes
  • Windows error codes converted to HRESULT values
  • Windows Media Device Manager error codes

For a complete list of possible error codes, see Error Codes.

Possible values include, but are not limited to, those in the following table.

Return code Description
E_INVALIDARG A parameter is an invalid or NULL pointer.
E_FAIL An unspecified error occurred.
WMDM_E_NOTSUPPORTED The device cannot report power capabilities.

Remarks

Only physical devices report power source capabilities and current power source. Software implementations of devices report no power capabilities or current power source.

Requirements

Header: Defined in wmsp.idl.

Library: mssachlp.lib

See Also