Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Below is the code i have been using to get remote registry information from windows 7 seats that have a 64 bit os. My issue is were expanding our company and a group that we just got has windows xp seats which is fine they will get upgraded but in the mean time the have netframework 3.5 and with that i can declare the registry view and i need them to beable to read a windows 7 64 bit registry. If someone can help me improve my code to make it more universal to use from in operating system and or architecture(x86 or x64) that would be great.

VB
Dim value
Dim localKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, strComputer, RegistryView.Registry64)
localKey = localKey.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI")
Dim value64 = localKey.GetValue("LastLoggedOnUser")

Dim localKey32 = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, strComputer, RegistryView.Registry32)
localKey32 = localKey32.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI")
Dim value32 = localKey32.GetValue("LastLoggedOnUser")

If value64 = Nothing Then
    value = value32
Else
    value = value64
End If

MsgBox(value.ToString)
Posted
Comments
ledtech3 15-Jun-12 23:39pm    
From the Code you posted, it Looks Like they are Getting the Exact same Registry key If it is 32 or 64 bit.
Are you trying to find out if the system you are trying to connect is 32 or 64 bit ? I have written programs for getting information from the registry that work on both 32 and 64 bit systems, but I have not done remote Registry. Is there something Different about remote than local ?

1 solution

Found in 60 seconds Googling for "read 64-bit registry from 32-bit process":

http://www.rhyous.com/2011/01/24/how-read-the-64-bit-registry-from-a-32-bit-application-or-vice-versa/[^]

...complete with examples.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900