🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #17470

Restore the part of registry

#17470
From: Onur Ekal
Date: Tue, 25 Mar 2003 18:58
42 lines
2304 bytes
I can backup a part of registry with that code in win2000/Xp on NTFS
(BCB6), with necessary permission, but I can't restore it.I tried
loadkey,restorekey, regrestorekey,
regloadkey, but I Can't. Please help about code...

Regards.

      HANDLE hToken;
      LUID luid;
      TOKEN_PRIVILEGES tp = {0};
      TOKEN_PRIVILEGES oldtp = {0};
      DWORD dwSize = sizeof(oldtp);
      if( !OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES |
      TOKEN_QUERY,&hToken) )
      {
          ShowMessage("OpenProcessToken() failed ");
          return ;
      }
      TCHAR *privs[] = { SE_BACKUP_NAME };
      if( !LookupPrivilegeValue(NULL, privs[0], &luid) )
      {
          ShowMessage("LookupPrivilege() failed ");
          return ;
      }
      tp.PrivilegeCount = 1;
      tp.Privileges[0].Luid = luid;
      tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
      if( !AdjustTokenPrivileges(hToken, FALSE, &tp,
sizeof(TOKEN_PRIVILEGES),
      &oldtp, &dwSize) )
      {
          ShowMessage("AdjustTokenPrivileges() failed ");
          CloseHandle (hToken);
          return;
      }
      TRegistry *Reg = new TRegistry;
      Reg->RootKey = HKEY_LOCAL_MACHINE;
      DeleteFile("c:\\001.reg");
      bool
f=Reg->SaveKey("\\SOFTWARE\\Microsoft\\WindowsNT\\CurrentVersion\\FontSubsti
tutes", "c:\\001.reg");
      if(!f)ShowMessage("Error");
Technical Details
Message-ID: <3e80a6f8@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,c49df41e5bfaab5f,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-03-25 11:03:55 PST
From: "Onur Ekal" <onurekal@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Restore the part of registry
Date: Tue, 25 Mar 2003 20:58:18 +0200
Lines: 45
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 213.153.165.168
Message-ID: <3e80a6f8@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1048618744 213.153.165.168 (25 Mar 2003 10:59:04 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail