The GetDevice method retrieves an audio endpoint device that is identified by an endpoint ID string.
public:
HRESULT GetDevice(
LPCWSTR pwstrId,
IMMDevice **ppDevice
)
pwstrId
Type: LPCWSTR
[in]
Pointer to a string containing the endpoint ID. The caller typically obtains this string from the IMMDevice::GetId method or from one of the methods in the IMMNotificationClient interface.
ppDevice
Type: IMMDevice **
[out]
Pointer to a pointer variable into which the method writes the address of the IMMDevice interface for the specified device. Through this method, the caller obtains a counted reference to the interface. The caller is responsible for releasing the interface, when it is no longer needed, by calling the interface’s Release method. If the GetDevice call fails, ppDevice* is **NULL.
Type: HRESULT
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 code | Description |
|---|---|
| E_POINTER | Parameter pwstrId or ppDevice is NULL. |
| E_NOTFOUND | The device ID does not identify an audio device that is in this system. |
| E_OUTOFMEMORY | Out of memory. |
Refer to WASAPI error codes.
If two programs are running in two different processes and both need to access the same audio endpoint device, one program cannot simply pass the device’s IMMDevice interface to the other program. However, the programs can access the same device by following these steps:
IMMDevice::GetId method in the first process to obtain the endpoint ID string that identifies the device.IMMDevice interface in the second process, the second program calls GetDevice with the endpoint ID string.For more information about the GetDevice method, see the following topics:
For code examples that use the GetDevice method, see the following topics:
Header: Declared in mmdeviceapi.h.
Library: Use MMDevApi.lib.