I have a MFC application created by the MFC Project Wizard. I wanted to save/read application settings in the registry and so asked this question to find a C++ Registry wrapper as the Windows API is very messy. However, I have now heard that the MFC provides a way to do this. Is this true? If so, how can I read/write values, see whether a key exists and get a list of all the keys?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
MFC provides an easy way to read/write Windows registry.
In your project you'll have a global CMyProjectName theApp;
object.
CMyProjectName
inherits CWinApp
class which provides the SetRegistryKey() method.
That method sets theApp
to write in the registry instead of an "ini" file.
In the documentation check out
CWinApp::GetProfileInt
CWinApp::GetProfileString
CWinApp::WriteProfileInt
CWinApp::WriteProfileString
methods on how to read and write integers and strings in the registry.