当我在 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,这一行可以删除。
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/