How does my existing app change the master volume on Vista?

After I posted the "How do I set the master volume in Vista", DanT commented:

Thanks Larry.  I'll have to send a link to this to the people at Griffin so they can fix my PowerMate.  I loved this volume knob on XP.  On Vista it only changes the volume for itself which is somewhat less than useful.

It turns out that we expected that this would be a common issue for our customers, so we built a mechanism into Vista to allow legacy applications to control the hardware using the old mixer APIs (I hinted about this in my original volume posts, but at the time we'd not finalized our plans, so I couldn't comment any more about it).

On Vista, the mixer APIs detect if your application is running in XP compatibility mode, and if your application is running in XP mode, it disables the virtualized mixer and instead allows the application to directly interact with the hardware.

 

Now this won't work for all applications (the XP mixer used to lie about the capabilities of the hardware (for instance it would create a fake volume control for audio hardware that didn't have a hardware volume control (like my laptop)), the Vista mixer won't lie), but it can be used to get existing applications (like the PowerMate application listed above) working on Vista.