LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

RegReadString with OS 64 Bits

Solved!
Go to solution

Good Morning,

I usually use the function RegReadString/RegWriteString to read and write on Windows Reg system.

 

It work without problems on Windows Vista and Windows7 32bits, but under WIndows7 64 Bit doesn't work.

 

Example :

 

#define WIN_KEY "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
iRtrn=RegReadString (REGKEY_HKLM, WIN_KEY,"ProductId", szBuffer, 256, &lSize);

 

This example normally return windows Product ID, but under Win7-64 I got error "Registry values doesn't exist"(-5068).

 

RegWriteString doesn't work too... 😞

 

 

Can you help me?

 

Thanks

Daniele

 

0 Kudos
Message 1 of 6
(4,052 Views)
Solution
Accepted by topic author d.ghisla

Hello Daniele,

 

One important thing to realize when running a 32 bit executable on 64 bit windows is that all registry requests will be redirected through the Wow6432Node.  For whatever reason, Microsoft has chosen not to place the product id information in the redirected location (HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion).  Only 64 bit applications are capable of reading from the non Wow6432Node location, where the product ID you are looking for is located.

 

Generally, the type of information you're looking for is best retrieved via WMI and some type of scripting such as VBScript.  Until CVI 2009 releases (giving you the ability to create native 64 bit applications) you will not be able to retrieve this information from the registry with a CVI application.

 

NickB

National Instruments 

0 Kudos
Message 2 of 6
(4,034 Views)

Is Retrieving the information in the registry is available in 2015 CVI release? This is because i have installed CVI 2015 release, still RegReadString returns the Registry value not exist.

I can see the installed software in Wow6432Node, but the function returns "Registry does not exist"

Could you help me how this can be done in the latest release?

0 Kudos
Message 3 of 6
(2,883 Views)

Did you install 64 Bit or 32 Bit LabWindows CVI?

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 6
(2,824 Views)

I didn't know a 64-bit release of CVI actually existed! Smiley Surprised

 

If you want to run through the WMI path that Nick suggested, then you can look at this example program I published: the Product ID can be found as SerialNumber in Operating System section:

How to get informations on the system through WMI in CVI



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 6
(2,815 Views)

@RobertoBozzolo wrote:

I didn't know a 64-bit release of CVI actually existed! Smiley Surprised

 


I can't say that I know, but it was the first thought that came up when seeing the description, having a few times fought with this dragon under LabVIEW. The other possible reason might be access rights, if the key is really there as the poster claims.

I would agree that using WMI is generally a better way to retrieve such information from the system, despite it being a somewhat heavy weight solution.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 6
(2,808 Views)