Instead of re-inventing the wheel, I’m using a utility called AutoHotkey. The scripting commands are self-explanatory and look like simple system API wrappers.
For example, to increase or decrease the master volume by 5, I chose WindowsKey+Up and WindowsKey+Down respectively, using the following script:
#Up::SoundSet, +5, master #Down::SoundSet, -5, master
You can read the complete list of supported commands here.