take ownership of registry key with .NET 2.0?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I spent tons of time searching the web for how to use .NET 2.0 and C# to
modify Registry key security. After finally finding an example, and once I
knew the function names a few other small examples.. I can still find
nothing that demonstrates how to take ownership of a Registry key if one
has (potentially) *only* "write owner"

The problem, of course is that normally, to read or change permissions, one
needs to "open" the registry key to get a handle to it.. but of course if
you do not have permission to do that, it fails and you get a null handle
which is pretty much useless for changing registry key access ;)

I open a root key:

RegistryKey myKey = Registry.ClassesRoot; // or whichever..

And try to open my sub key, which I only have "write owner" permission
(with "true" for write, since I want to write a new owner):

myKey = myKey.OpenSubKey("mySubKeyName", true);

Which, of course.. fails.

The issue is obviously known to MS, since they have a page specifically on
how to solve the problem in C++ (I think?) at:

http://support.microsoft.com/default.aspx?scid=kb;en-us;111546

Any help very much appreciated! -- Thanks!

--
Andrew
.



Relevant Pages

  • RE: user printers are not deleted after disconnecting user
    ... the redirected printers cannot be ... System has Full Control permission on the node, ... Control permission on this registry key. ... Delete the subkeys for the previously cached redirected printers in the ...
    (microsoft.public.windows.terminal_services)
  • RE: Access HKCU from an app with another set of credentials
    ... what is the exact registry key you want to ... What is the registry key's permission setting? ... The HKCU is only valid for the current logon user, if another user logon, ...
    (microsoft.public.dotnet.languages.vb)
  • RE: Application events after DC promotion to W2K3
    ... > The Network Service account used to run MSDTC did not have permission to ... > update the HKLM\Software\Microsoft\MSDTC registry key. ... This solved the MSDTC warnings. ...
    (microsoft.public.windows.server.migration)
  • Re: Problem about "StdRegProv" method
    ... > You may want to check if the user have the correct permission set on ... > the specific registry key on the remote machine. ... Microsoft® Windows®2000 Scripting Guide ...
    (microsoft.public.win32.programmer.wmi)
  • Re: Domain user could not change system DSN at ODBC
    ... Once i am connected to the domain, i could not add/change system DSN. ... I have allow full permission at the Registry Key HKLM> Sofware ... ODBC at Group Policy, but still problem persists. ...
    (microsoft.public.windows.group_policy)