Click here to Skip to main content
15,897,187 members
Articles / Desktop Programming / MFC

Very secure method to save and restore registry

Rate me:
Please Sign up or sign in to vote.
4.18/5 (10 votes)
23 Aug 20047 min read 71.5K   988   20  
This article gives a very secure method to save and restore registry keys. It provides a ready to use tool in both command-line and UI modes.
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// French (France) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
#ifdef _WIN32
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
#pragma code_page(1252)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE DISCARDABLE 
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE DISCARDABLE 
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE DISCARDABLE 
BEGIN
    "\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED


#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,0,1
 PRODUCTVERSION 1,0,0,1
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x40004L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040c04b0"
        BEGIN
            VALUE "Comments", "\0"
            VALUE "CompanyName", "\0"
            VALUE "FileDescription", "RegSR\0"
            VALUE "FileVersion", "1, 0, 0, 1\0"
            VALUE "InternalName", "RegSaveRestore\0"
            VALUE "LegalCopyright", "Copyright �2004,  A. YEZZA\0"
            VALUE "LegalTrademarks", "\0"
            VALUE "OriginalFilename", "RegSR.exe\0"
            VALUE "PrivateBuild", "\0"
            VALUE "ProductName", "RegSaveRestore\0"
            VALUE "ProductVersion", "1, 0, 0, 1\0"
            VALUE "SpecialBuild", "\0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x40c, 1200
    END
END

#endif    // !_MAC


/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_DIALOG1 DIALOG DISCARDABLE  0, 0, 250, 95
STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Save/Restore Registry Keys"
FONT 8, "MS Sans Serif"
BEGIN
    COMBOBOX        IDC_COMBO_CONF_FILE,66,2,163,57,CBS_DROPDOWN | CBS_SORT | 
                    WS_VSCROLL | WS_TABSTOP
    PUSHBUTTON      "...",IDC_BUTTON_BROWSE_FILE,231,2,15,12,BS_FLAT
    COMBOBOX        IDC_COMBO_ROOT,66,16,72,56,CBS_DROPDOWNLIST | WS_VSCROLL | 
                    WS_TABSTOP
    COMBOBOX        IDC_COMBO_KEY_PATH,66,31,181,42,CBS_DROPDOWN | CBS_SORT | 
                    WS_VSCROLL | WS_TABSTOP
    COMBOBOX        IDC_COMBO_IN_OUT_FILE,66,45,163,48,CBS_DROPDOWN | 
                    CBS_SORT | WS_VSCROLL | WS_TABSTOP
    PUSHBUTTON      "...",IDC_BUTTON_BROWSE_FILE1,231,45,15,12,BS_FLAT
    DEFPUSHBUTTON   "Save Key",IDC_BUTTON_SAVE,91,78,50,13,BS_FLAT
    PUSHBUTTON      "Restore Key",IDC_BUTTON_RESTORE,144,78,57,13,BS_FLAT
    PUSHBUTTON      "Get error description",IDC_BUTTON_GET_ERR_DESC,147,60,
                    99,12,BS_FLAT | WS_DISABLED
    PUSHBUTTON      "Quit",IDCANCEL,209,78,38,13,BS_FLAT
    RTEXT           "Config. file:",IDC_STATIC,3,3,60,9
    RTEXT           "Root:",IDC_STATIC,3,18,60,9
    RTEXT           "Key path:",IDC_STATIC,3,32,60,9
    RTEXT           "[IN/Out]put file:",IDC_STATIC,3,45,60,9
    CONTROL         "",IDC_STATIC,"Static",SS_ETCHEDHORZ | SS_NOTIFY,2,75,
                    246,1
    RTEXT           "Result:",IDC_STATIC,3,60,60,9
    EDITTEXT        IDC_EDIT_RESULT,66,61,75,12,ES_READONLY | NOT WS_BORDER
    LTEXT           "�2004,  A. YEZZA",IDC_STATIC,3,81,79,9,WS_DISABLED
END


/////////////////////////////////////////////////////////////////////////////
//
// Dialog Info
//

IDD_DIALOG1 DLGINIT
BEGIN
    IDC_COMBO_ROOT, 0x403, 5, 0
0x4b48, 0x5543, "\000" 
    IDC_COMBO_ROOT, 0x403, 5, 0
0x4b48, 0x4d4c, "\000" 
    IDC_COMBO_ROOT, 0x403, 8, 0
0x4b48, 0x5355, 0x5245, 0x0053, 
    IDC_COMBO_ROOT, 0x403, 9, 0
0x4b48, 0x5543, 0x4352, 0x4746, "\000" 
    0
END


/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME           ICON    DISCARDABLE     "res\\RegSR.ico"

/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE 
BEGIN
    IDD_DIALOG1, DIALOG
    BEGIN
        BOTTOMMARGIN, 92
    END
END
#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// String Table
//

STRINGTABLE DISCARDABLE 
BEGIN
    IDS_USAGE               "_____________________________________________________________\nUSAGE:\nRegSR /UI|/S|/R /H:ROOT /K:KEY /P:FILE /C:[CONF_FILE]\n\n/UI\tLaunch the program in User Interface mode.\n\tNo more parameter is needed in this case.\n/S\tTo Save a registry key to file.\n/R\tTo Restore a registry key from file.\n\nROOT\tTake HKCU, HKLM, HKUSERS or HKCURCFG.\nKEY\tSubkey path.\nFILE\tInput file in restore mode or Output file in save mode.\nCONF_FILE\tConfig file used to secure restoring data.\n\t\tIt contains also other informations.\n_____________________________________________________________"
    IDS_EXAMPLE             "\nExamples:\n   RegSR /S /H:HKLM /K:Software\\MyKey /P:C:\\MyKey.dat /C:C:\\RegConf.ini\n   RegSR /R /H:HKLM /K:Software\\MyKey /P:C:\\MyKey.dat /C:C:\\RegConf.ini\n   RegSR /UI"
    IDS_COPYRIGHT           "\n________________________\nCopyright �2004, A. YEZZA"
END

#endif    // French (France) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions