开发者

Trust the Registry Keys or the Environment Variables

I have a program I am making in C++ WinAPI &a开发者_StackOverflowmp; 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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜