IPortableDeviceManager::GetDeviceFriendlyName method (portabledeviceapi.h)

Retrieves the user-friendly name for the device.

Syntax

HRESULT GetDeviceFriendlyName(
  LPCWSTR pszPnPDeviceID,
  WCHAR   *pDeviceFriendlyName,
  DWORD   *pcchDeviceFriendlyName
);

Parameters

pszPnPDeviceID

Pointer to a null-terminated string that contains the device's Plug and Play ID. You can retrieve a list of Plug and Play names of all devices that are connected to the computer by calling GetDevices.

pDeviceFriendlyName

A caller-allocated buffer that is used to hold the user-friendly name for the device. To learn the required size for this parameter, first call this method with this parameter set to NULL and pcchDeviceFriendlyName set to 0; the method will succeed and set pcchDeviceFriendlyName to the required buffer size to hold the device-friendly name, including the termination character.

pcchDeviceFriendlyName

On input, the maximum number of characters that pDeviceFriendlyName can hold, not including the termination character. On output, the number of characters that is returned by pDeviceFriendlyName, not including the termination character.

Return value

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

Return code Description
HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)
The supplied buffer is not large enough to hold the device description. (Refer to the value returned in pcchDeviceDescription for the required size.)
HRESULT_FROM_WIN32(ERROR_INVALID_DATA)
The device description could not be found.
S_OK
The method succeeded.
E_POINTER
At least one of the required arguments was a NULL pointer.

Remarks

A device is not required to support this method. If this method fails to retrieve a name, try requesting the WPD_OBJECT_NAME property of the device object (the object with the ID WPD_DEVICE_OBJECT_ID).

Requirements

   
Target Platform Windows
Header portabledeviceapi.h
Library PortableDeviceGUIDs.lib

See also

IPortableDeviceManager Interface

IPortableDeviceManager::GetDevices