Microsoft DirectX 8.1 (C++)

Enumeration of Capture Devices

For an application that is simply going to capture sounds through the user's preferred capture device, you don't need to enumerate the available devices. By passing NULL or a predefined GUID to DirectSoundCaptureCreate8 or DirectSoundFullDuplexCreate8,you can create a default device. For more information, see Creating the DirectSoundCapture Object.

If you are looking for a particular kind of device or wish to offer the user a choice of devices, you must enumerate the devices available on the system.

Enumeration serves three purposes:

To enumerate devices, first set up a callback function that will be called each time DirectSound finds a device. You can do anything you want within this function, and you can give it any name, but you must declare it in the same form as the DSEnumCallback prototype. The callback function must return TRUE if enumeration is to continue, or FALSE otherwise—for instance, after finding a device with the capabilities you need.

For a sample callback function, see Enumeration of Sound Devices. Note that a GUID for each device is obtained as one of the parameters to this function.

The enumeration is set in motion by using the DirectSoundCaptureEnumerate function, as follows:

DWORD pv;  // Can be any 32-bit type.
 
HRESULT hr = DirectSoundCaptureEnumerate(
    (LPDSENUMCALLBACK)DSEnumProc,
    (VOID*)&pv);