views:

171

answers:

3

Here's the problem.

I'm getting the following string as parameter to my function:

HKEY_CURRENT_USER\Software\MyProgram\SomeKey

where SomeKey is a

REG_DWORD

and has a value. I need to read and write to that key (SomeKey) but all the registry functions that I know take HKEY_CURRENT_USER separately from the rest of the key (\Software\MyProgram\SomeKey). Is there any API or function to pass the whole string and retrieve the value from that key? and to write a value to that key?

If not, anyone knows a good, fast way to do this?

thanks

A: 

Try RegQueryValue(Ex) and RegSetValue(Ex). You can look them up on msdn.

Danra
Thanks, but as I mention I need to read the whole string as one. In order to use the functions you mention I need to use RegOpenKeyEx() which if you look in the MSDN require as a 1st param an HKEY which in my case is embedded in the string. The question was if you know a good way to do this having a whole string. I really don't want to start parsing strings which frankly is a pain in the a.
wonderer
+1  A: 

You will have to split the string in your function to determine the correct hive to make the call against.

Joe
I know I will have to do that. I just didn't want to have to start parsing strings. C is not very friendly when it comes to string parsing.
wonderer
C is just fine for parsing strings. IN this case it's easy, you're just looking for the first slash. There's your two tokens.
Joe
OK, and the snippet of code...
wonderer
The answer for parsing the string is on another question I asked.
wonderer
A: 

Wonderer the answer to your question as you have asked it, and provided rather unhelpful comments about, is no.

You will need to actually do some work, and actually write some codes since there is no build in API that will take a string you have written above and do what you ask. Microsoft have assumed that people would be willing to do that small little bit of code themselves.

So the answer to your question is no there is not an api function that does what you ask.

Toby Allen