Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[The feature associated with this page, DirectSound, is a legacy feature. It has been superseded by XAudio2 and Audio Graphs. These newer frameworks have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use XAudio2 and Audio Graphs instead of DirectSound, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]
Information about system-wide DirectSound device properties can be obtained from an object of class CLSID_DirectSoundPrivate (11AB3EC0-25EC-11d1-A4D8-00C04FC28ACA). This class supports the IKsPropertySet interface. The CLSID and properties are defined in Dsconf.h.
To create an object of this classCall the LoadLibrary function to load Dsound.dll.
Call the GetProcAddress function to obtain the DllGetClassObject function.
Call DllGetClassObject to obtain the IClassFactory interface of the class factory for the CLSID_DirectSoundPrivate class.
Call IClassFactory::CreateInstance to create the CLSID_DirectSoundPrivate object and retrieve the IKsPropertySet interface (IID_IKsPropertySet).
The CLSID_DirectSoundPrivate object supports one property set, DSPROPSETID_DirectSoundDevice (84624F82-25EC-11d1-A4D8-00C04FC28ACA). This property set exposes the following three read-only properties.
DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE
DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING
This property retrieves the DirectSound device GUID corresponding to a specified Windows Multimedia device name.
Property data is contained in a DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_DATA structure, available in ANSI and Unicode versions. This structure has the following members.
| Member | Type | Description |
|---|---|---|
| DeviceName | String | [in] Name of device |
| DataFlow | DIRECTSOUNDDEVICE_DATAFLOW | [in] Direction of data flow, either DIRECTSOUNDDEVICE_DATAFLOW_RENDER or DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE |
| DeviceID | GUID | [out] DirectSound device ID |
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION
This property retrieves a full description of a DirectSound device specified by GUID.
Property data is contained in a DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA structure, available in ANSI and Unicode versions. This structure has the following members.
| Member | Type | Description |
|---|---|---|
| Type | DIRECTSOUNDDEVICE_TYPE | [out] Device type: DIRECTSOUNDDEVICE_TYPE_EMULATED, DIRECTSOUNDDEVICE_TYPE_VXD or DIRECTSOUNDDEVICE_TYPE_WDM |
| DataFlow | DIRECTSOUNDDEVICE_DATAFLOW | [in, out] Direction of data flow, either DIRECTSOUNDDEVICE_DATAFLOW_RENDER or DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE |
| DeviceID | GUID | [in] DirectSound device GUID, or NULL for the default device of the type specified by DataFlow |
| Description | String | [out] Description of DirectSound device |
| Module | String | [out] Module name of the DirectSound driver |
| Interface | String | [out] PnP device interface name |
| WaveDeviceID | ULONG | [out] Identifier of the corresponding Windows Multimedia device |
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE
This property enumerates all DirectSound render or capture devices.
Property data is contained in a DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA structure, available in Ansi and Unicode versions. This structure has the following members.
| Member | Type | Description |
|---|---|---|
| Callback | LPFNDIRECTSOUNDDEVICEENUMERATECALLBACK | [in] Application-defined callback function. When IKsPropertySet::Get is called, this function is called once for each device enumerated. It takes as parameters a DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA structure describing the enumerated device, and the value in Context. |
| Context | LPVOID | [in] User-defined value to be passed to the callback function for each device enumerated. |