IWMDMDevice::GetName
The GetName method retrieves the human-readable name of the media device.
Syntax
HRESULT GetName(LPWSTRpwszName,UINTnMaxChars);
Parameters
pwszName
[out] Pointer to a (Unicode) wide-character, null-terminated string specifying the device name. The buffer is allocated and released by the caller.
nMaxChars
[in] Integer specifying the maximum number of characters that can be placed in pwszName, including the termination character.
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 pwszName parameter is an invalid or NULL pointer. |
WMDM_E_NOTSUPPORTED | The device does not have a name. |
WMDM_E_BUFFERTOOSMALL | The buffer specified is too small for the return string. Check nMaxChars for the required buffer size. |
E_FAIL | An unspecified error occurred. |
Example Code
The following C++ code retrieves the device display name.
// Get the device name.
const UINT MAX_CHARS = 100;
WCHAR name[MAX_CHARS];
hr = pIWMDMDevice->GetName((LPWSTR)&name, MAX_CHARS);
if (hr == S_OK)
// TODO: Display the retrieved name.
Requirements
Header: Defined in mswmdm.h.
Library: mssachlp.lib
See Also