" />
开发者

Controlling WriteProfileString

Is it possible to specify the application name which is used by CWinApp::WriteProfileString()?

If I use CWinApp::SetRegistryKey to set the name of my company to "MyCompany", and I call AfxGetApp()->WriteProfileString in my application called "SomeApp", my string will be stored under the following registry key:

HKEY_CURRENT_USER\Software\MyCompany\SomeApp\...

The problem is that my users want to run multiple versions of SomeApp. So in order that the registry settings don't conflict I want to store them in keys like this:

HKEY_CURRENT_USER\Software\MyCompany\SomeApp 1.1\...

HKEY_CURRENT_USER\Software\MyCompany\SomeApp 2.0\...

etc.

I could replace all instances of WriteProfileString with my own function, but this would be quite difficult as it is used exte开发者_运维技巧nsively in both our source code and some of the third-party libraries that we use.

Is there some way to force WriteProfileString to use a different string for the application name?


This code in the app constructor worked well:

  free((void*)m_pszProfileName);
  free((void*)m_pszRegistryKey);
  m_pszRegistryKey = _tcsdup(L"nobugz");
  m_pszProfileName = _tcsdup(L"myapp\\1.0");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜