在基于对话框的程序中备份/还原注**册**表

解决方案 »

  1.   

    搜索了以前的帖子,问及此问题的不少,均无结果。本人给出注册表一个键的备份方法,关于遍历注册表的过程可以自己添加。API函数RegSaveKey的功能有限。
    #include<fstream>
    void C...Dlg::OnButton1() //注册表备份
    {
    std::ofstream tfile("C:\\...\\back.reg",std::ios::out);
    tfile<<"REFEDIT4\n\n"; tfile<<"[HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\]\n";
    tfile<<"\"Test1\" =\"Adam\"\n";
    tfile<<"\"Test2\"=hex:61\n";
    tfile<<"\"Test3\"=dword:00000064\n";
    tfile.close();
    }void C...Dlg::OnButton2() //注册表恢复
    {
    system("C:\\...\\back.reg");//请先备份注册表
    }
      

  2.   

    http://www.vckbase.com/document/viewdoc.asp?id=724
      

  3.   

    void CRegDlg::OnButton24() //注册表备份
    {
        ShellExecute(NULL,"open","C:\\Windows\\Regedit.exe","/e \"C:\\back.reg\"",NULL,SW_SHOWNORMAL);
    }
    void CRegDlg::OnButton25() //注册表恢复
    {
        ShellExecute(NULL,"open","C:\\Windows\\Regedit.exe","/s \"C:\\zzq.reg\"",NULL,SW_SHOWNORMAL);
    }