🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
2 messages
2 total messages Started by Onur Ekal Tue, 25 Mar 2003 18:58
Restore the part of registry
#17470
Author: 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");
Re: Restore the part of registry
#17386
Author: Vladimir Afanasyev
Date: Wed, 26 Mar 2003 10:44
16 lines
1409 bytes
Hi,

"Onur Ekal" <onurekal@hotmail.com> wrote:
>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...
>

I did not try to do it.
But I am sure. If you set SE_BACKUP_NAME for registry backup 
you need to set SE_RESTORE_NAME for restoring registry.
SE_RESTORE_NAME  - defined in winnt.h.

Vladimir.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads