Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Thu, 30 Mar 2006 04:07:39 -0800,    group: microsoft.public.win32.programmer.tools        back       


How to use "RegSaveKey"?   
Dear all!
     I try to make a backup of the registry!
     first,I open the key and save the handle like this:
          RegOpenKeyEx  
(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services",NULL,KEY_ALL_AC 
CESS,(PHKEY)&hKey);

     then,I try to save it to a txt file:
           RegSaveKey(hKey,"f:\\abc.txt",null);

      but an error occur:"A required privilege is not held by the client."

all  codes:
int _tmain(int argc, _TCHAR* argv[])
{
	HKEY  hKey;
	HLOCAL hlocal = NULL;

    DWORD dwError = 
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services",NULL,KEY_ALL_ACCESS,(PHKEY)&hKey);
	if(dwError == ERROR_SUCCESS)
	{
  

	dwError = RegSaveKey(hKey,"f:\\abc.txt",null);  

        if(dwError == ERROR_SUCCESS)
		   MessageBox(NULL,"ok!",NULL,MB_OK);

		else
		{
            FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | 
FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, dwError, MAKELANGID(LANG_ENGLISH, 
SUBLANG_ENGLISH_US),(PTSTR)&hlocal, 0, NULL);
            MessageBox(NULL,(LPCSTR)hlocal,NULL,MB_OK);
		}
		RegCloseKey(hKey);
	}
	return 0;
}
date: Thu, 30 Mar 2006 04:07:39 -0800   author:   troylees

RE: How to use "RegSaveKey"?   
he problem has been solved.The process which calls RegSaveKey must have got 
the authority of SE_BACKUP_NAME.  See :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/regsavekey.asp


"troylees" wrote:

> Dear all!
>      I try to make a backup of the registry!
>      first,I open the key and save the handle like this:
>           RegOpenKeyEx  
> (HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services",NULL,KEY_ALL_AC 
> CESS,(PHKEY)&hKey);
> 
>      then,I try to save it to a txt file:
>            RegSaveKey(hKey,"f:\\abc.txt",null);
> 
>       but an error occur:"A required privilege is not held by the client."
> 
> all  codes:
> int _tmain(int argc, _TCHAR* argv[])
> {
> 	HKEY  hKey;
> 	HLOCAL hlocal = NULL;
> 
>     DWORD dwError = 
> RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Services",NULL,KEY_ALL_ACCESS,(PHKEY)&hKey);
> 	if(dwError == ERROR_SUCCESS)
> 	{
>   
> 
> 	dwError = RegSaveKey(hKey,"f:\\abc.txt",null);  
> 
>         if(dwError == ERROR_SUCCESS)
> 		   MessageBox(NULL,"ok!",NULL,MB_OK);
> 
> 		else
> 		{
>             FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | 
> FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, dwError, MAKELANGID(LANG_ENGLISH, 
> SUBLANG_ENGLISH_US),(PTSTR)&hlocal, 0, NULL);
>             MessageBox(NULL,(LPCSTR)hlocal,NULL,MB_OK);
> 		}
> 		RegCloseKey(hKey);
> 	}
> 	return 0;
> }
>
date: Thu, 30 Mar 2006 08:22:02 -0800   author:   troylees

Re: How to use "RegSaveKey"?   
troylees wrote:

> he problem has been solved.The process which calls RegSaveKey must have got 
> the authority of SE_BACKUP_NAME.  See :

Another thing, the files saved by RegSaveKey() are not text files, they 
are binary database files that can be used only by the RegLoadKey(), 
RegRestoreKey() and RegReplaceKey() functions.

-- 
Olof Lagerkvist
ICQ: 724451
Web: http://here.is/olof
date: Sat, 01 Apr 2006 00:56:28 GMT   author:   Olof Lagerkvist ess

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us