This .NET API works OK if I'm trying to open the Registry in a machine that's in the same domain as I am (and my logged-on user has admin rights on the target machine).
It gets tricky if it's an out-of-domain machine with a different, local administrative user (of whom I do have the password).
I tried to use WNetUseConnection() (which has served me well in the past in situations where what I wanted was to read a remote disk file) prior to calling OpenRemoteBaseKey(), but no dice -- I get an access denied exception.
Clearly, I must pass credentials some other way, but how?
What I've used successfully to access files on a computer is the following code:
And then for signing in part, just use:
As you might see, "Undo()" will make that you are no longer signed in as that user. So don't use it before you're done. But don't forget to use it!