IDeviceTopology::GetDeviceId method

The GetDeviceId method gets the device identifier of the device that is represented by the device-topology object.

Syntax


HRESULT GetDeviceId(
  [out] LPWSTR *ppwstrDeviceId
);

Parameters

ppwstrDeviceId [out]

Pointer to a pointer variable into which the method writes the address of a null-terminated, wide-character string that contains the device identifier. The method allocates the storage for the string. The caller is responsible for freeing the storage, when it is no longer needed, by calling the CoTaskMemFree function. If the GetDeviceId call fails, *ppwstrDeviceId is NULL. For information about CoTaskMemFree, see the Windows SDK documentation.

Return value

If the method succeeds, it returns S_OK. If it fails, possible return codes include, but are not limited to, the values shown in the following table.

Return codeDescription
D_POINTER

Pointer ppwstrDeviceId is NULL.

E_OUTOFMEMORY

Out of memory.

 

Remarks

The device identifier obtained from this method can be used as an input parameter to the IMMDeviceEnumerator::GetDevice method.

For a code example that uses the GetDeviceId method, see Using the IKsControl Interface to Access Audio Properties.

Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Header

Devicetopology.h

See also

IDeviceTopology Interface
IMMDeviceEnumerator::GetDevice

 

 

Show: