c++ - 为什么 MFC 要我设置注册表项?

标签 c++ visual-studio-2010 mfc registrykey

当我在 Visual Studio 2010 中创建我的 MFC C++ 应用程序时,以下代码行被放置在我的主源文件中 InitInstance() 内:

// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T(""));

它说我应该将字符串修改为适当的内容,但我认为我从未使用过注册表项。使用 SetRegistryKey 有什么意义,我的程序的用户是否会看到该字符串?我应该删除这段代码吗?

最佳答案

这是样板代码,如果您使用注册表来读取/写入应用程序数据,则需要进行调整。

如果不使用registry,这一行可以删除。

参见 CWinApp::SetRegistryKey :

Causes application settings to be stored in the registry instead of INI files.

....

This function sets m_pszRegistryKey, which is then used by the GetProfileInt, GetProfileString, WriteProfileInt, and WriteProfileString member functions of CWinApp. If this function has been called, the list of most recently-used (MRU) files is also stored in the registry. The registry key is usually the name of a company. It is stored in a key of the following form: HKEY_CURRENT_USER\Software\<company name>\<application name>\<section name>\<value name>.

关于c++ - 为什么 MFC 要我设置注册表项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29287495/

相关文章:

c++ - 删除彼此太靠近的 vector 线?

c++ - Vector of Base unique_ptr 在 emplace_back(new T()) 上导致对象切片

c++ - 是否可以将 lambda 表达式放入 C++ 中的映射或列表中?

visual-studio-2010 - 如何使用构建后事件 checkout -复制- checkin TFS 中的文件?

C++ 预处理器宏选择参数

C++ 与 gcc 和 visual studio 的不同编译错误, 'within this context'

mysql - 需要指导我的 Visual Basic 应用程序安装

.net - 我的对话节点在创建 mfc 项目时丢失了

c++ - #include "MyClass.h"和 #include ".\myclass.h"有什么区别

c++ - COleControl的ActiveX和HWND