Link to home
Start Free TrialLog in
Avatar of cophi
cophi

asked on

Save Property Page

I have a custom active X.  On that property page I've added 3 CEdit controls.  What's the best way to save those values so when I use the control again, the boxes are prepopulated with them.

Thanks,
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cophi
cophi

ASKER

Hey AndyAinscow, that sounds good but could you provide an example?  
Check in the help file - I'm out of the office for the next hour or so.  sorry.
eg.
      CRegKey regKey;
      if(SUCCEEDED(regKey.Open(HKEY_CURRENT_USER, _T("SOFTWARE\\MYAPP"))))      
      {
            regKey.SetStringValue(_T("Benutzer"), _T("Me"));
      }
You may refer this 'CRegSettings - registry helper class' Src Code :

http://www.codeproject.com/system/regsettings.asp <===== Simple class to store application settings in registry  

-MAHESH
Above is easy to use as  to Load use and Save From and To Registry.

//Call constructor to set values
CMySettings settings(HKEY_CURRENT_USER, "Software\\%s\\%s\\%i", "MyCompany", "MyApplication", intValue);

..
settings.Load(); // Load configuration

    ... // use values settings.Value1 etc.
       
    settings.Save(); // Save configuration

Refer above link CMySettings class src files for more.

-MAHESH
Alternatively you have look at this : http://www.codeproject.com/cpp/siv_settings.asp <==Simple settings implementation

This one saves settings in text file. Dialog application demo with Edit controls are there to demonstrate saving settings.

-MAHESH
Avatar of cophi

ASKER

Why does this fail???

#define GLOBALREGKEY HKEY_LOCAL_MACHINE
#define GLOBALREGLOCATION "ABC\\Test\\Configurations"

if(l_regKey.Create(GLOBALREGKEY, GLOBALREGLOCATION, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_WRITE)==ERROR_SUCCESS)
Extract from help.
If successful, returns ERROR_SUCCESS and opens the key. If the method fails, the return value is a nonzero error code defined in WINERROR.H.

long lRet = l_regKey.Create(GLOBALREGKEY, GLOBALREGLOCATION, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_WRITE);
if(lRet==ERROR_SUCCESS)
{
Do your stuff
}
else
{
TRACE("Create failed with %ld\n", lRet);
}


What do you get as the returned value in the TRACE output?
Avatar of cophi

ASKER

87
Avatar of cophi

ASKER

#define GLOBALREGLOCATION "ABC\\Test\\Configurations"

apparantly 87 is invalid parameter.

does the globalreglocation have to be a location thats already created.  I figured this would create the whole 'tree' for you.
Avatar of cophi

ASKER

Um apparantly it didn't like HKEY_LOCAL_MACHINE
HKEY_CURRENT_USER worked??

Any ideas y
User rights - could it be you don't have suitable rights to modify keys in HKEY_LOCAL_MACHINE ?