Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to undo SetRegistryKey

Status
Not open for further replies.

tasuki78

Programmer
Jun 12, 2003
7
US
Hi there. I hope someone can help me out with this problem.
I have an app in MFC that uses SetRegistryKey to write out to the registry the system settings of my program. I want to know whether there is a way to undo this so that I can also write out to an INI file. THis will enable me to have settings exported.
 
From RegEdit you can export a tree to a .reg file.

/JOlesen
 
IS there a way to do it from the application rather then having to go through Regedit?
 
Don't think so ....
However it can't be that difficult to write some code to do the export to a file - and some code to import from the same file.

/JOlesen
 
Wow i am totally lost so excuse my ignorance here. You can read/write/delete registry keys and values from applications. You can also of course write data to a file including .ini files. If this is completely irrelevant just ignore it. ;-)

-pete
 
I think I understand where you guys are coming from. But maybe I better elaborate a little first. I was using SetRegistryKey in order to save to the registry, the system settings that I want to be able to recall when the application loads. I use the calls to GetProfile and WriteProfile which by default writes to an INI file. Using SetRegistryKey sets the redirection to the registry key, but I don't know of a way to undo the SetRegistry and write back to an INI. What do you all think of this problem? I think I can get around it by using the CIniEx code I found online.
 
How about:
class Configuration
{
public:
virtual UINT GetProfileInt( LPCTSTR lpszSection, LPCTSTR lpszEntry, int nDefault )=0;
BOOL WriteProfileInt( LPCTSTR lpszSection, LPCTSTR lpszEntry, int nValue )=0;
// and the other Get & Write's...
};

class RegConfiguration : Configuration
{
// Implement Configuration by access to registry
};

class IniConfiguration : Configuration
{
// Implement Configuration by access to .INI file
};

/Per
Nerdy signatures are as lame as the inconsistent stardates of STTNG.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top