Click to See Complete Forum and Search --> : Registry keys


CornedBee
January 10th, 2004, 06:47 PM
If I copy a HKEY using RegOpenValueEx:
HKEY orig, copy;
RegOpenValueEx(orig, 0, 0, 0, &copy);
I get a different value in copy than orig. Is there any way I can still test if the refer to the same key?

Marc G
January 11th, 2004, 03:34 AM
HKEY's are handles to a registry key. Each handle is different, but different handles can point to the same registry key.

CornedBee
January 11th, 2004, 05:35 AM
I know that. I want to find out if two distinct HKEYs point to the same key.

Marc G
January 11th, 2004, 08:12 AM
Ah, sorry, didn't know you already knew ;)

Perhaps you can use RegQueryInfoKey to query info of both HKEY's and see if they are the same.

wey97
January 11th, 2004, 09:58 AM
You can only open a key or query a value. RegOpenValueEx doesn't exist in the Windows API.

I think maybe you mean RegOpenKeyEx or RegQueryValueEx. ;)

So you're looking at a registry value and you want to know if two HKEYs that point to a value are the same I suppose. If you compare the strings you passed to open the HKEYs and you check that the values are the same, then you would know that the HKEYs are the "same" but maybe I'm oversimplifying your problem.

CornedBee
January 11th, 2004, 12:30 PM
RegOpenValueEx, yeah :o

The whole thing is part of an OO API to the registry, and I don't have access to any of the strings used to open the keys.

But I solved it differently by now, thanks to the people at cprogramming.com

Marc G
January 11th, 2004, 01:03 PM
And what was the solution?

CornedBee
January 11th, 2004, 04:20 PM
I didn't copy the HKEYs, instead I wrote a shared_hkey class, similar to a reference counting smart pointer.