Kyle Williamson
Kyle Williamson

Reputation: 2184

Why does MFC want me to set a registry key?

When I created my MFC C++ application in Visual Studio 2010, the following lines of code were placed in my main source file inside InitInstance():

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

It says that I should modify the string to something appropriate, however I don't think I ever use a Registry Key. What is the point of using SetRegistryKey and will the string ever be seen by the user of my program? Should I just delete this block of code?

Upvotes: 0

Views: 2335

Answers (1)

AlexD
AlexD

Reputation: 32576

This is a boilerplate code, to be adjusted if you use registry to read/write application data.

If you don't use registry, this line can be deleted.

See 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>.

Upvotes: 5

Related Questions