共用方式為


確定非標準格式支援

[與此頁面相關聯的功能,波形音訊,是舊版功能。 WASAPIAudio Graphs已取代它。 WASAPI音訊圖形 已針對 Windows 10 和 Windows 11 優化。 Microsoft強烈建議新的程式碼在可能的情況下使用WASAPIAudioGraphs,而不是波形音頻。 Microsoft建議使用舊版 API 的現有程式代碼,盡可能改寫成使用新的 API。]

若要查看裝置是否支援特定格式(標準或非標準),您可以使用 WAVE_FORMAT_QUERY 旗標呼叫 waveOutOpen 函式。 下列範例會使用這項技術來判斷超聲波音頻裝置是否支援指定的格式。

// Determines whether the specified waveform-audio output device 
// supports a specified waveform-audio format. Returns 
// MMSYSERR_NOERROR if the format is supported, WAVEERR_BADFORMAT if 
// the format is not supported, and one of the other MMSYSERR_ error 
// codes if there are other errors encountered in opening the 
// specified waveform-audio device. 
 
MMRESULT IsFormatSupported(LPWAVEFORMATEX pwfx, UINT uDeviceID) 
{ 
    return (waveOutOpen( 
        NULL,                 // ptr can be NULL for query 
        uDeviceID,            // the device identifier 
        pwfx,                 // defines requested format 
        NULL,                 // no callback 
        NULL,                 // no instance data 
        WAVE_FORMAT_QUERY));  // query only, do not open device 
} 

用於判斷非標準格式支援的這項技術也適用於超聲波音頻輸入設備。 唯一的差異在於,waveInOpen 函式會用來取代 waveOutOpen 來查詢格式支援。

若要判斷系統中任何超聲波音頻裝置是否支援特定的超聲波音頻數據格式,請使用上一個範例中說明的技術,但為 uDeviceID 參數指定WAVE_MAPPER常數。