|
-
July 2nd, 2008, 02:27 AM
#1
Read 64-bit registry with 32-bit app
Please help.
This is classic problem: I want to read Vista ProductId in my app.
The problem is my .NET application is 32-bit and Vista is 64-bit.
I can't believe that it is impossible to do, but I couldn't so far, as
LM = Registry::LocalMachine->OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\");
LMS = Convert::ToString(LM->GetValue("ProductId"));
returns NULL...
Thank you.
-
August 18th, 2008, 08:00 PM
#2
Re: Read 64-bit registry with 32-bit app
Hi alekh. I saw your question and I thought I'd help out.
I've had success reading 64-bit Registry values from a 32-bit application. The trick is to use RegOpenKeyEx() to read your values. To read anything from the 64-bit area of the Registry, you must bitwise OR KEY_WOW64_64KEY with the flag that you would normally pass into the samDesired parameter.
Follow this link: http://msdn.microsoft.com/en-us/library/ms724897.aspx for Microsft's documentation of the RegOpenKeyEx() function.
Once you have it working on a 64-bit version of Windows, if you have problems with it not working on a 32-bit version of Windows with KEY_WOW64_64KEY OR'd with the samDesired parameter, you might want to try calling GetProcAddress() first to see if it returns a pointer for "IsWow64Process". If it returns NULL, then don't OR the KEY_WOW64_64KEY flag with the samDesired parameter of the RegOpenKeyEx() call. (My code plays it safe by only ORring the flag in if it knows it's running on a 64-bit OS.)
- Rob
-
January 24th, 2011, 10:00 PM
#3
Re: Read 64-bit registry with 32-bit app
I did extensive research on this and found that in .NET 4 it is handled easy with managed code, but prior to .NET 4, you have to load DLLIMport advapi32.dll.
Here is my research.
http://www.rhyous.com/2011/01/24/how...or-vice-versa/
-
January 25th, 2011, 01:51 PM
#4
Re: Read 64-bit registry with 32-bit app
Welcome to the forums, Rhyous. 
Please remember to make your posts relevant. This thread is 3 years old!
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|