MMDeviceEnumerator

wraps the IMMDeviceEnumerator interface and provides methods for enumerating multimedia device resources.

Authors

License

Documentation

Requirements

AutoHotkeyAHK_L v1.1+
OSWindows Vista, Windows 2008 Server or higher
Base classesUnknown
Helper classesEDataFlow, ERole, DEVICE_STATE
Other classes(MMDeviceCollection, MMDevice, MMNotificationClient)
Summary
MMDeviceEnumeratorwraps the IMMDeviceEnumerator interface and provides methods for enumerating multimedia device resources.
Variables
CLSIDThis is CLSID_MMDeviceEnumerator.
IIDThis is IID_IMMDeviceEnumerator.
Functions
EnumAudioEndpointsgenerates a collection of audio endpoint devices that meet the specified criteria.
GetDefaultAudioEndpointretrieves the default audio endpoint for the specified data-flow direction and role.
GetDeviceretrieves an audio endpoint device that is identified by an endpoint ID string.
RegisterEndpointNotificationCallback
UnregisterEndpointNotificationCallback

Variables

CLSID

This is CLSID_MMDeviceEnumerator.  It is required to create an instance.

IID

This is IID_IMMDeviceEnumerator.  It is required to create an instance.

Functions

EnumAudioEndpoints

EnumAudioEndpoints(dataFlow,
mask)

generates a collection of audio endpoint devices that meet the specified criteria.

Parameters

UINT dataFlowThe data-flow direction for the endpoint devices in the collection.  You can use the fields of the EDataFlow enumeration class for convenience.  You should set this parameter either EDataFlow.eRender or EDataFlow.eCapture.
UINT maskThe state or states of the endpoints that are to be included in the collection.  You can use a combination (or just one) of the fields in the DEVICE_STATE enumeration class for convenience.

Returns

MMDeviceCollection collectiona new instance of the MMDeviceCollection class

GetDefaultAudioEndpoint

GetDefaultAudioEndpoint(dataFlow,
role)

retrieves the default audio endpoint for the specified data-flow direction and role.

Parameters

UINT dataFlowThe data-flow direction for the endpoint device.  You can use the fields of the EDataFlow enumeration class for convenience.  You should set this parameter either EDataFlow.eRender or EDataFlow.eCapture.
UINT roleThe role of the endpoint device.  You can use the fields of the ERole enumeration class for convenience.  You should set this parameter either to ERole.eConsole, ERole.eMultimedia or ERole.eCommunications.

Returns

MMDevice endpointa new instance of the MMDevice class

Remarks

In Windows Vista, the MMDevice API supports device roles but the system-supplied user interface programs do not.  The user interface in Windows Vista enables the user to select a default audio device for rendering and a default audio device for capture.  When the user changes the default rendering or capture device, the system assigns all three device roles (eConsole, eMultimedia, and eCommunications) to that device.  Thus, GetDefaultAudioEndpoint always selects the default rendering or capture device, regardless of which role is indicated by the role parameter.  In a future version of Windows, the user interface might enable the user to assign individual roles to different devices.  In that case, the selection of a rendering or capture device by GetDefaultAudioEndpoint might depend on the role parameter.  Thus, the behavior of an audio application developed to run in Windows Vista might change when run in a future version of Windows.  For more information, see <Device Roles in Windows Vista at url target=”http://msdn.microsoft.com/en-us/library/windows/desktop/dd370821” name=”http://msdn.microsoft.com/en-us/library/windows/desktop/dd370821”(v=vs.85).aspx>.

GetDevice

GetDevice(id)

retrieves an audio endpoint device that is identified by an endpoint ID string.

Parameters

STR ida 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.

Returns

MMDevice devicea new instance of the MMDevice class

RegisterEndpointNotificationCallback

RegisterEndpointNotificationCallback(client)

Parameters

MMNotificationClient clienteither a MMNotificationClient instance or a pointer to it

Returns

BOOL successtrue on success, false otherwise.

UnregisterEndpointNotificationCallback

UnregisterEndpointNotificationCallback(client)

Parameters

MMNotificationClient clienteither a MMNotificationClient instance or a pointer to it

Returns

BOOL successtrue on success, false otherwise.
EnumAudioEndpoints(dataFlow,
mask)
generates a collection of audio endpoint devices that meet the specified criteria.
GetDefaultAudioEndpoint(dataFlow,
role)
retrieves the default audio endpoint for the specified data-flow direction and role.
GetDevice(id)
retrieves an audio endpoint device that is identified by an endpoint ID string.
RegisterEndpointNotificationCallback(client)
UnregisterEndpointNotificationCallback(client)