IDirectSoundBuffer8::GetFormat Method

The GetFormat method retrieves a description of the format of the sound data in the buffer, or the buffer size needed to retrieve the format description.


HRESULT GetFormat(
         LPWAVEFORMATEX pwfxFormat,
         DWORD dwSizeAllocated,
         LPDWORD pdwSizeWritten


  • pwfxFormat
    Address of a WAVEFORMATEX or WAVEFORMATEXTENSIBLE structure that receives a description of the sound data in the buffer. To retrieve the buffer size needed to contain the format description, specify NULL. In this case the variable at pdwSizeWritten receives the size of the structure needed to receive the data.
  • dwSizeAllocated
    Size, in bytes, of the structure at pwfxFormat. If pwfxFormat is not NULL, this value must be equal to or greater than the size of the expected data.
  • pdwSizeWritten
    Address of a variable that receives the number of bytes written to the structure at pwfxFormat. This parameter can be NULL.

Return Value

If the method succeeds, the return value is DS_OK. If the method fails, the return value may be DSERR_INVALIDPARAM.


The format structure can have a variable length that depends on the format. Before retrieving the format description, the application should query the buffer object for the size of the format by calling this method and specifying NULL for the pwfxFormat parameter. The necessary size of the structure is returned in the pdwSizeWritten parameter. The application can then allocate sufficient memory and call GetFormat again to retrieve the format description.


Header: Declared in DSound.h.

Library: Use Dsound3d.dll.

See Also