Click here to Skip to main content
13,558,704 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have a small piece of code that I used to change the wave volume of on windows XP. I used

public static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);

public static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);

When I use this code on windwos 7. and change volume

int NewVolume = ((ushort.MaxValue / 10) * currentVolume);
// 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);

The volume is not getting changed. When i opened the master volume window of win7 I could see the volume level bar getting changed but the volume change was not happening.

I know there are other ways to do the same thing on windows 7 but I was just wondering why the volume is not changing if my function call is able to set the volume bar to the required level?
Posted 29-Feb-12 0:41am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


since Windows Vista/7 MS changed the access to control volume, mixers, etc. and it's called the coreaudio API.
Here are some links, I'm sure you can work something out with it:[^]
Vista Core Audio API Master Volume Control[^][^]

You can also use or have a look at NAudio Wrapper:[^]

Good Luck ;)
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I made the experience that the waveOutSetVolume and waveOutGetVolume Functions only change the volume ouput of your current application and not the master system volume. therefore the volume is raised or lowered but you dont see any change on the master volume scrollbar. open the mixer and take a look there.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03-2016 | 2.8.180515.1 | Last Updated 8 Mar 2015
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100