SetupPreferredAudioDevices 關鍵字表示慣用的音訊裝置,這是當系統包含一或多個音訊裝置時,音訊系統預設會啟用的裝置。 此關鍵字是媒體類別特定的,並受 Microsoft Windows Millennium Edition/Windows 98、Microsoft Windows 2000、Windows XP 和 Windows Vista 的支援。 SetupPreferredAudioDevices在 Windows 7 中不支援。
建立音訊裝置時,應用程式可以選擇使用預設 (或偏好) 裝置,而不是明確指定裝置。 (For example, see the descriptions of the waveOutOpen and DirectSoundCreate functions in the Microsoft Windows SDK documentation.)
音訊系統會在系統登錄中追蹤目前偏好的音訊裝置。 當使用者藉由安裝新的音訊裝置來升級系統時,安裝裝置的專屬 INF 檔案通常會更新登錄,以將新裝置指定為慣用的音訊裝置。
The SetupPreferredAudioDevices keyword can appear within a registry-update directive in the add-registry-section (see INF AddReg Directive) of an INF file for an audio device. 此指示詞具有下列格式:
reg-rootkey, [reg-subkey]SetupPreferredAudioDevices [flags], [dword-value]
該指令指示音頻系統使用設備的音頻功能作為聲音播放、錄音和 MIDI 音樂播放的默認值。 Following installation, these three defaults appear in the Sounds and Multimedia control panel under the Audio tab. The user can use Control Panel to change the default devices.
The directive's dword-value parameter specifies a DWORD value that should be nonzero in order to enable the directive. 如果此值為零,則指引無效。 Because Windows Me/98 do not support the REG_DWORD registry data type, however, dword-value is typically expressed as a 4-byte REG_BINARY type instead of as a DWORD (for example, as "01,00,00,00" instead of "0x00000001"). The dword-value parameter can be specified in raw binary format by setting the directive's flags parameter to "1" (FLG_ADDREG_BINVALUETYPE).
指示詞會在安裝裝置驅動程式時生效。 如果在安裝新裝置時,另一個裝置佔據偏好裝置的角色,則指引會導致新裝置擔任偏好裝置的角色,從而將另一個裝置從此角色中取代。
升級或重新安裝已安裝裝置的驅動程式時,您可能想要避免變更使用者目前偏好的裝置選擇,以進行音效播放、音效錄製和 MIDI 音樂播放。 If so, set the FLG_ADDREG_NOCLOBBER bit in the flags parameter, which causes the directive to take effect only if this is the device's initial installation.
範例
下列範例是 INF 檔案的一部分,示範如何使用 SetupPreferredAudioDevices 關鍵字:
AddReg = XYZ-Audio-Device.AddReg
...
[XYZ-Audio-Device.AddReg]
HKR,,SetupPreferredAudioDevices,3,01,00,00,00
範例結尾的指示詞指定名為「XYZ-Audio-Device」的裝置現在是慣用的音訊裝置。 HKR 是登錄中音訊裝置的根金鑰。 The flags parameter is set to 3, which is the bitwise OR of FLG_ADDREG_BINVALUETYPE and FLG_ADDREG_NOCLOBBER. 後者可防止裝置現有的慣用裝置登錄專案在裝置已安裝且其驅動程式只是升級時覆寫。 指示詞結尾的四個位元組會指定非零值,這是啟用指示詞的必要條件。
With the current implementation of the SetupPreferredAudioDevices keyword in Windows Vista, any audio endpoint with its dword-value set to an odd number can be set as the default device. 若要確定正確的端點已設定為預設裝置,請確定最後公開包含相關端點的 KS 篩選。 您必須這樣做,因為 AudioEndpointBuilder 服務用來填入屬性存放區和設定預設裝置的演算法。