Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

reading VISTA ProductID using RegOpenKeyEx

18 views
Skip to first unread message

Michele Puccini

unread,
Feb 7, 2008, 9:08:33 AM2/7/08
to
I amy trying to read the Vista ProductID from registry but I always get a
"parameter incorrect" error.
The ProductID reading C++ code I use works correctly for XP and Win2000 and
even for WinME/98/95.

The code is simple:
I open the location HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\ProductID" using RegOpenKeyEx with read-only attributes
(KEY_READ).

Of course RegEdit works very well and reads the ProductID of Vista without
complains.

Where's my error ? Looks like a security issue but I have no clue..

Mik
--


Sam of California

unread,
Feb 18, 2008, 12:57:48 PM2/18/08
to
WMI provides a way to get that and it would be independent of the Windows
version.


"Michele Puccini" <m...@c-l-a-s-s-x.it> wrote in message
news:WhEqj.50$Yd7...@nntpserver.swip.net...

Michele Puccini

unread,
Feb 19, 2008, 3:50:50 AM2/19/08
to
Thanks Sam. I'll check this out.

Some pointers to vc++ wmi-registry samples ?

Mik

--

"Sam of California" <sam...@social.rr.com_change_social_to_socal> ha scritto
nel messaggio news:47b9c6fe$0$17322$4c36...@roadrunner.com...

Sam of California

unread,
Feb 19, 2008, 5:51:10 PM2/19/08
to
The first thing to understand is that WMI provides a version-independent way
to do things. Anything you can do using WMI is likely to always work for
versions of Windows that implements the WMI class and all susequent versions
of Windows. WMI is a Microsoft implementation of an industry standard.

If you use WMI to read the registry (it is possible) then you are not
geeting the benefits of WMI. The registry is not documented and therefore is
likely to change, or at least you should assume it will change. You should
not assume that an undocumented solution will always work. WMI provides
documented solutions for requirements such as yours.

The Windows/Platform SDK has sample WMI code. Look at the WMI documentation.
The Technet Script Center has many sample uses of WMI; eventhough they are
scripts, they show the general use of WMI for many things and then anything
they do, you can do using WMI. Just be aware that the amount of C++ code
will be much greater than equivalent script code.


"Michele Puccini" <m...@c-l-a-s-s-x.it> wrote in message

news:PMwuj.6$LY6...@nntpserver.swip.net...

Michele Puccini

unread,
Feb 20, 2008, 3:10:41 AM2/20/08
to
Many thanks Sam,

I've read some articles about WMI (thanks for the pointers) and indeed it
seems to be very useful in many ways.
I understand that the c++ code may be more compex/greater than the scripting
counterpart.
Unfortunately I would have to deal with WMI from a DLL and I susppose that
I'll be forced to use c++.

Cheers,

Mik
--


"Sam of California" <sam...@social.rr.com_change_social_to_socal> ha scritto

nel messaggio news:47bb5d3c$0$16660$4c36...@roadrunner.com...

0 new messages