The win32 function 'SHGetFolderPath" is what you want. You can pass in environment variables like APPDATA, PROGRAM_FILES, SYSTEM and it will return the path on the current system...

http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx