如何通过MFC在注册表中保存应用程序设置? [英] How can save Application Settings in the Registry via MFC?

查看:169
本文介绍了如何通过MFC在注册表中保存应用程序设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由MFC项目向导创建的MFC应用程序。我想在注册表中保存/读取应用程序设置,因此要求问题找到C ++注册表包装器作为Windows API是非常混乱。但是,我现在听说,MFC提供了一种方法来做到这一点。这是真的?

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?

推荐答案

如果是这样,我可以读取/写入值,看看键是否存在, MFC提供了一种读/写Windows注册表的简单方法。

MFC provides an easy way to read/write Windows registry.

在您的项目中,您将拥有一个全局 CMyProjectName theApp; 对象。

CMyProjectName 继承 CWinApp 类,提供 SetRegistryKey()方法。

该方法设置 theApp 注册表而不是ini文件。

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.

在文档检查中

CWinApp::GetProfileInt
CWinApp::GetProfileString
CWinApp::WriteProfileInt
CWinApp::WriteProfileString

有关如何在注册表中读取和写入整数和字符串的方法。

methods on how to read and write integers and strings in the registry.

这篇关于如何通过MFC在注册表中保存应用程序设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆