Wednesday, January 5, 2011

SetRegistryKey() is irretating during debugging

If you are writing your application, and you are run & test, you want to see the change on every code variation.

However, if you have SetRegistryKey() running, your app will start the app with the last setting save in the registry. This include Windows position & size etc.

However, you can delete the function couse you will have assert error. So how to do it?

By using Unregister(). SetRegistry() can be found in App::InitInstance(). See following.

BOOL CFEAApp::InitInstance()
{
 //Other Code
 AfxEnableControlContainer();
 SetRegistryKey(_T("aaa"));
 LoadStdProfileSettings(4);  // Load standard INI file options (including MRU)
 
 //Just add the following unregister() after LoadStfProfileSetting()
 Unregister();

 //Other Code
 return TRUE;
}

No comments:

Post a Comment