My code for Linux is really simplistic, I basically just run the command:
pactl set-sink-port @DEFAULT_SINK@ analog-output-headphones
with TProcess.
Just to explain briefly what my project is, I basically have a RaspberryPi + DAC that acts as a server (with VLC socket interface + Icecast + a server in Python I have coded).
My client (basically a player/remote controler connected to VLC on the Pi) is coded with Lazarus, and as a source client for Icecast it uses ices2 on Linux and Butt on Windows (both with TProcess again) for streaming the input from your soundcard. Proper music files are handled by my Python server and played locally by VLC on the Pi.
So now what I want to achieve on Windows is just what I do on Linux, switch the output when you start to stream your soundcard to the Pi so you don't hear and the DAC and your laptop playign the same sound...