I want to change the program's volume (and not master volume). I have the following code right now:
DllImport("winmm.dll")]
public static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);
[DllImport("winmm.dll")]
public static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);
private void volumeBar_Scroll(object sender, EventArgs e)
{
// Calculate the volume that's being set
int NewVolume = ((ushort.MaxValue / 10) * volumeBar.Value);
// Set the same volume for both the left and the right channels
uint NewVolumeAllChannels = (((uint)NewVolume & 0x0000ffff) | ((uint)NewVolume << 16));
// Set the volume
waveOutSetVolume(IntPtr.Zero, NewVolumeAllChannels);
}
This only works on Win XP, not Windows 7 (and probably Vista neither). I've not found any script that will achieve the same on Win 7, only to change the master volume (which I am not after).
0
. The volume doesn't change either. – Ansela