Retired Microsoft Blog disclaimer

This directory is a mirror of retired "Decrypt My World" MSDN blog and is provided as is. All posting authorship and copyrights belong to respective authors.
Original URL: https://blogs.msdn.microsoft.com/alejacma/2010/01/13/how-to-set-sound-volume-programmatically/
Post name: How to set sound volume programmatically
Original author: Alejandro Campos Magencio
Posting date: 2010-01-13T03:43:00+00:00


Hi all,

From time to time I like to post aboutother issues which are not related tocrypto stuff, but I consider useful because of thenumber of request I get on them. And this is one commonquestion I've seen: how do I set sound volume programmatically on Windows?

On Windows XP we can manipulate audio settings with Wave API or Dsound API (Direct Sound). The following function may help here: waveOutSetVolume.Here is the rest of the API: Waveform Functions. And herewe can find a .NET sample which mixes .NET classes and that API: Using P/Invoke to Call Unmanaged APIs from Your Managed Classes. Another sample, this time from a third-party: Mute volume in vb.net program.

On Windows Vista and later that API is no longer available. We may use MMDevice API and EndpointVolume API instead. Here you can see some samples: How do I change the master volume in Windows Vista & Vista Core Audio API Master Volume Control.

I hope this helps.

Regards,

Alex (Alejandro Campos Magencio)


Share this article:

Comments:

Comments are closed.