It was necessary to programmatically switch the audio output device by default. For example, the system has several audio devices installed - Speakers, Realtek HD Audio 2nd output, Realtek Digital Output, nVidia HDMI Output (Port 1), nVidia HDMI Output (Port 3), nVidia HDMI Output (Port 3) .
It is necessary to programmatically make the user-selected device the default device in the system.
Google, but did not find a working solution, except for WinXP.
Tried to use the following code found in the open spaces:
uses MMSystem; const DRVM_MAPPER = $2000; DRVM_MAPPER_PREFERRED_GET = DRVM_MAPPER+21; DRVM_MAPPER_PREFERRED_SET = DRVM_MAPPER+22; .... function ChangePrimarySndOutDevice(dev: cardinal): integer; begin result := waveOutMessage(HWAVEOUT(WAVE_MAPPER), DRVM_MAPPER_PREFERRED_SET, dev, 0); end; I also saw that you need to transfer the current and new devices to the waveOutMessage function, so I tried this option:
function ChangePrimarySndOutDevice2(olddev, newdev: cardinal): integer; begin result := waveOutMessage(HWAVEOUT(WAVE_MAPPER), DRVM_MAPPER_PREFERRED_SET, olddev, newdev); end; Unfortunately, it did not work out.
I do not need to play the sound, I just would like to install in the system (Windows 7+) the default playback device that the user chose as if he did it through the Control Panel , the Sound snap-in.