Share via


IWMDeviceManager::GetDeviceCount

banner art

The GetDeviceCount method retrieves the number of portable devices that are currently connected to the computer.

Syntax

HRESULT GetDeviceCount(DWORD*pdwCount);

Parameters

pdwCount

[out]  Pointer to a DWORD specifying the count of known devices.

Return Values

The method returns an HRESULT. All the interface methods in Windows Media Device Manager 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 an extenstive list of possible error codes, see Error Codes.

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

Return code Description
S_OK The method succeeded.
E_INVALIDARG The pdwCount parameter is an invalid or NULL pointer.
E_FAIL An unspecified error occurred.

Example Code

The following C++ code retrieves a count of devices from a global IWMDeviceManager interface.

HRESULT hr = S_OK;

// Print number of devices.
DWORD iDevices = 0;
hr = m_IWMDeviceMgr->GetDeviceCount(&iDevices);
if (hr == S_OK)
{
    // TODO: Display the count of devices.
}

Requirements

Header: Defined in mswmdm.h.

Library: mssachlp.lib

See Also