How does Audacity control the mixer volume on the computer?

I am creating an automatic-gain-control using VBA and Excel. (My major project is on Excel).

It looks as if when I change the speaker level in Audacity, it changes the system volume level.
I would like to know the code that is being used.

I hear that Audacity is written in C and I do have a vague recollection of that from my college years abut if I can at least see the code, maybe I can translate it or be able to ask questions in a programming forum.

Audacity uses PortAudio to communicate with the sound system: http://www.portaudio.com/