[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

Need help trying to backup the registry...

qwerty

9/21/2007 12:33:00 PM

Hello,

I am trying to clean up the registry and I would like to backup the
keys I delete into .hiv files.using RegSaveKey and RegRestoreKey from
the advapi32.dll.

I have managed to declare them:

[StructLayout(LayoutKind.Sequential)]
public struct SECURITY_ATTRIBUTES
{
public int nLength;
public IntPtr lpSecurityDescriptor;
public int bInheritHandle;
}

[DllImport("advapi32.dll", EntryPoint = "RegSaveKey")]
public static extern int RegSaveKeyA(int hKey, string lpFile,
ref SECURITY_ATTRIBUTES lpSecurityAttributes);

[DllImport("advapi32.dll", EntryPoint = "RegRestoreKey")]
public static extern int RegRestoreKeyA(int hKey, string lpFile, int
dwFlags);

But I do not know how to use them!

Would you know:
- How do I get the hKey value? Do I have to use either RegCreateKeyEx
or RegOpenKeyEx?
- How do I initialize lpSecurityAttributes ?

Any help in C# would be very very appreciated!

thanks,
Michael

--
Michael
----
http://michael.moren...
http://port.cogoli...