SandVox is really not ideal to show source code, so I will simply make screenshots and make the code available for download in a separate file linked to below.
These are three helper functions I use in Win32 code:
If it's worth it (or maybe for completeness' sake), you can download the code here.