IDirectSoundBuffer::GetFormat

The IDirectSoundBuffer::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 lpwfxFormat,  
  DWORD dwSizeAllocated,   
  LPDWORD lpdwSizeWritten  
);
 

Parameters

lpwfxFormat
Address of the WAVEFORMATEX structure to contain 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 DWORD pointed to by the lpdwSizeWritten parameter will receive the size of the structure needed to receive complete format information.
dwSizeAllocated
Size, in bytes, of the WAVEFORMATEX structure. DirectSound writes, at most, dwSizeAllocated bytes to that pointer; if the WAVEFORMATEX structure requires more memory, it is truncated.
lpdwSizeWritten
Address of a variable to contain the number of bytes written to the WAVEFORMATEX structure. This parameter can be NULL.

Return Values

If the method succeeds, the return value is DS_OK.

If the method fails, the return value may be DSERR_INVALIDPARAM.

Remarks

The WAVEFORMATEX structure can have a variable length that depends on the details of the format. Before retrieving the format description, the application should query the DirectSoundBuffer object for the size of the format by calling this method and specifying NULL for the lpwfxFormat parameter. The size of the structure will be returned in the lpdwSizeWritten parameter. The application can then allocate sufficient memory and call IDirectSoundBuffer::GetFormat again to retrieve the format description.

QuickInfo

  Windows NT: Use version 4.0 or later.
  Windows: Use Windows 95 or later. Available as a redistributable for Windows 95.
  Windows CE: Unsupported.
  Header: Declared in dsound.h.
  Import Library: Use dsound.lib.

See Also

IDirectSoundBuffer, IDirectSoundBuffer::SetFormat