user593747
user593747

Reputation: 1514

Trust the Registry Keys or the Environment Variables

I have a program I am making in C++ WinAPI & I need to determine the version of Windows the user is running & the path to Program Files.

I know I can determine this by looking at the Windows Environment Variables or the Registry Keys(can I get the path to program files from the Registry?) BUT which is better practice?

I know Environment Variables can be changed easily so its not good to trust them, but can the registry keys be changed as easily - which is better to trust?

Is it better practice to go to the Registry for this information or the Environment Variables? Which would you do?

Upvotes: 0

Views: 166

Answers (1)

Simon Mourier
Simon Mourier

Reputation: 139095

You 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

Upvotes: 3

Related Questions