Discussion:
How to read registry values in vc++
(too old to reply)
Sridhar
2009-08-14 10:42:01 UTC
Permalink
Hi i tried to read registry values by using the following code. some part is
working fine.when i first openkey and read values from them and i closed the
key using CloseKey.it is working fine. after that i again openkey with some
other registry path.
but now it is not opening..please tell me what is the probleml.


CString baseReg = "SOFTWARE\\DataCollectionTool";

pReg.OpenKey(CRegistry::localMachine, baseReg);

----
---
pReg1.GetValue("TOOLID",appNodes[i].ToolId);

----
//this is working fine...i closed they key by using
pReg1.CloseKey();
pReg.CloseKey();
-------
------
//when i write the following code..it is not working.

CString baseRegUsb =
"SYSTEM\\CurrentControlSet\\Enum\\USB\\Vid_058f&Pid_6387";

pRegUsb.OpenKey(CRegistry::localMachine, baseRegUsb);
----
---
//this part not working and also it is not showing any error.
plese anybody help me what is the problem..it is really frustrating..


--------------------------------------------
Sridhar
2009-08-14 14:35:01 UTC
Permalink
This post might be inappropriate. Click to display it.
Tim Roberts
2009-08-16 04:32:20 UTC
Permalink
Post by Sridhar
it is easy solution guys..i am posting the solution here bcoz it may help
someone.
generally accessing Enum registry values wont possible. we have to change
the permisson of the key by right clicking on the key and selecting
permission option.
we have to make it as full control for Everyone.
That's only needed if you want to change something. If you only need to
read an Enum key, you can do that with the default permissions. You just
have to pass READ_KEY when you open the key.
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
Sridhar
2009-08-17 06:56:01 UTC
Permalink
Hi Tim,
Thanks for ur reply..could you explain how to pass READ_KEY with some code.
i am new to vc++.
i only need to read the enum key values.(actually i have to read USB key
values).

Thanks in advance.
--
--------------------------------------------
At last i did something for today...:)
Post by Tim Roberts
Post by Sridhar
it is easy solution guys..i am posting the solution here bcoz it may help
someone.
generally accessing Enum registry values wont possible. we have to change
the permisson of the key by right clicking on the key and selecting
permission option.
we have to make it as full control for Everyone.
That's only needed if you want to change something. If you only need to
read an Enum key, you can do that with the default permissions. You just
have to pass READ_KEY when you open the key.
--
Providenza & Boekelheide, Inc.
Scot T Brennecke
2009-08-17 07:14:39 UTC
Permalink
Post by Sridhar
Hi Tim,
Thanks for ur reply..could you explain how to pass READ_KEY with some code.
i am new to vc++.
i only need to read the enum key values.(actually i have to read USB key
values).
Thanks in advance.
Actually, Sridhar, you never told us what class you were using to do the registry access. There's an ATL class called CRegKey that
is similar to what you're doing, but it's method is called Open (not OpenKey). If you use the CRegKey class, however, the Open
method takes a parameter indicating the desired access. Of course, you don't have to use a prepackaged class at all; you could just
use the Windows API functions directly:
RegOpenKeyEx Function (Windows):
http://msdn.microsoft.com/en-us/library/ms724897(VS.85).aspx
RegQueryValueEx Function (Windows):
http://msdn.microsoft.com/en-us/library/ms724911(VS.85).aspx
RegCloseKey Function (Windows):
http://msdn.microsoft.com/en-us/library/ms724837(VS.85).aspx
Sridhar
2009-08-17 07:46:01 UTC
Permalink
Thanks scot for ur information.
could you please help me on another post that made in this forum?
please see the post below this post titled as "could somebody help on
this..new to vc++"

Thanks in advance.
--
--------------------------------------------
At last i did something for today...:)
Post by Scot T Brennecke
Post by Sridhar
Hi Tim,
Thanks for ur reply..could you explain how to pass READ_KEY with some code.
i am new to vc++.
i only need to read the enum key values.(actually i have to read USB key
values).
Thanks in advance.
Actually, Sridhar, you never told us what class you were using to do the registry access. There's an ATL class called CRegKey that
is similar to what you're doing, but it's method is called Open (not OpenKey). If you use the CRegKey class, however, the Open
method takes a parameter indicating the desired access. Of course, you don't have to use a prepackaged class at all; you could just
http://msdn.microsoft.com/en-us/library/ms724897(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms724911(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms724837(VS.85).aspx
Scot T Brennecke
2009-08-18 06:38:59 UTC
Permalink
Post by Sridhar
Thanks scot for ur information.
could you please help me on another post that made in this forum?
please see the post below this post titled as "could somebody help on
this..new to vc++"
Thanks in advance.
Well, I experimented a little with your code, but I don't have any experience with writing journal hooks. That type of question
really belongs in a group about Win32 programming, not one for the VC++ language or compiler.
Tim Roberts
2009-08-18 02:59:15 UTC
Permalink
Post by Sridhar
Thanks for ur reply..could you explain how to pass READ_KEY with some code.
i am new to vc++.
i only need to read the enum key values.(actually i have to read USB key
values).
Really, if you don't know how to look up the parameter list for the
registry class you are using, then I'm wondering what you plan to do with
the information you're getting through the Enum key.
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
Continue reading on narkive:
Loading...