Take ownership of registry key with .NET 2.0?
How does one go about taking ownership of a registry key using VB.NET 2008 *IF* one has only TakeOwnership privilege?
The problem is exactly as specified in MS KB Article ID: 111546 at:
http://support.microsoft.com/kb/111546/EN-US/
...except that I would like to know how to do it in VB.NET 2008
Any help would be much appreciated. Thanks!
Re: Take ownership of registry key with .NET 2.0?
That article gives you the answer. It tells you that need to use the RegOpenKeyEx API. I think that example is in C#, but that's not a big deal. Just look up the API on Google, MSDN, PInvoke, or all of them.
Re: Take ownership of registry key with .NET 2.0?
Yeah I looked out and got these two functions for VB.NET
vb Code:
Declare Auto Function RegOpenKeyEx Lib "advapi32.dll" ( _
ByVal hKey As IntPtr, _
ByVal lpSubKey As String, _
ByVal ulOptions As Integer, _
ByVal samDesired As Integer, _
ByRef phkResult As Integer _
) As Integer
Declare Function RegSetKeySecurity Lib "advapi32" (ByVal hKey As Long, ByVal SecurityInformation As Long, ByVal pSecurityDescriptor As Security.SecurityZone) As Long
Now how to use them to get what I want
Re: Take ownership of registry key with .NET 2.0?
Bump......
I tried a lot but couldn't find anything
Re: Take ownership of registry key with .NET 2.0?
What exactly did you try?