GetDeviceID

[The feature associated with this page, DirectSound, is a legacy feature. It has been superseded by WASAPI and Audio Graphs. Media Casting have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Media Casting instead of DirectSound, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The GetDeviceID function retrieves the unique device identifier of the default playback and capture devices selected by the user in Control Panel.

Syntax

HRESULT GetDeviceID(
         LPCGUID pGuidSrc,
         LPGUID pGuidDest
)

Parameters

  • pGuidSrc
    Address of a variable that specifies a valid device identifier, or the address of one of the following predefined variables.

    Value Description
    DSDEVID_DefaultPlayback System-wide default audio playback device.
    DSDEVID_DefaultCapture System-wide default audio capture device.
    DSDEVID_DefaultVoicePlayback Default voice playback device.
    DSDEVID_DefaultVoiceCapture Default voice capture device.
  • pGuidDest
    Address of a variable that receives the unique identifier of the device.

Return Value

If the function succeeds, it returns DS_OK. If it fails, the return value may be DSERR_INVALIDPARAM.

Remarks

If pGuidSrc points to a valid device identifier, the same value is returned in pGuidDest. If pGuidSrc is one of the listed constants, pGuidDest returns the address of the corresponding device GUID.

Requirements

Header: Declared in DSound.h.

Library: Use Dsound.lib.