确定Wow6432Node注册表的操作系统类型

时间:2010-10-14 16:35:31

标签: vb.net

我需要检查注册表中的值。该应用程序(Cisco VPN)是一个32位应用程序,因此在64位操作系统上安装时使用Wow6432Node。

选择使用哪个字符串的最佳方法是什么?检查操作系统是否为x64,如果第一次失败,尝试读取一个,然后另一个读取?或者有更好的方法吗?

Dim keyName64 As String = "HKEY_LOCAL_MACHINE\Software\Wow6432Node\Cisco Systems\VPN Client"
Dim keyName32 As String = "HKEY_LOCAL_MACHINE\Software\Cisco Systems\VPN Client"

使用.net 4.0框架?:

 Dim registryKey As RegistryKey
    If Environment.Is64BitOperatingSystem = True Then
        registryKey = registryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64)
        Else
        registryKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32)
        End If

1 个答案:

答案 0 :(得分:1)

您只需要检查代码是否以64位模式运行。这很简单:

Dim key As String
If IntPtr.Size = 8 Then key = keyName64 Else key = keyName32
相关问题