IWMDeviceManager2::GetDeviceFromCanonicalName method (mswmdm.h)

The GetDeviceFromCanonicalName method retrieves an IWMDMDevice interface for a device with a specified canonical name. You can retrieve a device's canonical name by calling IWMDMDevice2::GetCanonicalName.


HRESULT GetDeviceFromCanonicalName(
  LPCWSTR     pwszCanonicalName,
  IWMDMDevice **ppDevice



A wide-character, null-terminated string specifying the canonical name of the device.


Pointer to a pointer to the IWMDMDevice interface of the device object with the specified canonical name. The caller must release this interface when done with it.

Return value

The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return code Description
The pwszCanonicalName or ppDeviceArray parameter is an invalid or NULL pointer.
There is no connected device found with canonical name pwszCanonicalName.


This method can be useful if an application implements IWMDMNotification, which sends a canonical name notification when a device connects or disconnects from the computer.


Target Platform Windows
Header mswmdm.h
Library Mssachlp.lib

See also

IWMDMDevice2 Interface

IWMDeviceManager2 Interface