Trust the Registry Keys or the Environment Variables
See the question and my original answer on StackOverflowYou should use the GetVersionEx Function API instead. It's better than the environment variable and the registry.
For the path to program files, there is also an API: SHGetFolderPath Function