Registry

G

Guest

I'm converting c++ code to c#. Here the interface declarations for the 2
should remain same. so if I have interface declaration as below

object GetRegistryKey(long keyParent, string keyPath, string keyName) in c++
I need to keep it the same in c# also.

basically the function access values inside a registry given the path/name,
also keyparent above refers to hkey (eg:localmachine/currentuser etc.).

In .net we can use Registry and Registrykey to access registry where as in
c++ HKEY values are used, which have values as showed below,

eg: HKEY_CLASSES_ROOT = &H80000000
HKEY_CURRENT_USER = &H80000001
HKEY_LOCAL_MACHINE = &H80000002

now my problem is to convert this long # which comes in as the input to
registry.localmachine. Is this possible if so, how?

Thanks for any help.
 
M

Mattias Sjögren

now my problem is to convert this long # which comes in as the input to
registry.localmachine. Is this possible if so, how?

You'll have to do the mapping yourself, something like this

const uint HKEY_CLASSES_ROOT = 0x80000000;

....

RegistryKey keyParent;

switch (val)
{
case HKEY_LOCAL_MACHINE:
keyParent = Registry.LocalMachine;

...
}



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top