reg key check导致崩溃

时间:2013-03-17 20:33:14

标签: .net vb.net registry regedit

我在这里有这个功能,它检查它是否在注册表中,如果是,则返回true,如果不是则返回false。但是,它每次都会崩溃

R = My.Computer.Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)

以下是整个功能:

Private Function CheckKey2() As Boolean
Dim R As RegistryKey
    Dim V() As String
    Dim O As String = vbNullString
    R = My.Computer.Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
    V = R.GetValueNames()
    R.Close()

    For Each Str As String In V
        O = O & Str & "|"
    Next
    If O.Contains(MyValue) Then
        Return True
    Else
        Return False
    End If
End Function

以下是我的注册表中的内容

Key Name:          HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Class Name:        <NO CLASS>
Last Write Time:   10/30/2012 - 6:19 AM
Value 0
 Name:            RtHDVCpl
 Type:            REG_SZ
 Data:            C:\Program Files\Realtek\Audio\HDA\RAVCpl64.exe -s

Value 1
 Name:            Kernel and Hardware Abstraction Layer
 Type:            REG_SZ
 Data:            KHALMNPR.EXE

Value 2
  Name:            AdobeAAMUpdater-1.0
  Type:            REG_SZ
  Data:            "C:\Program Files (x86)\Common Files\Adobe\OOBE\PDApp\UWA\UpdaterStartupUtility.exe"

Value 3
  Name:            TortoiseHgOverlayIconServer
  Type:            REG_SZ
  Data:            C:\Program Files\TortoiseHg\TortoiseHgOverlayServer.exe

Value 4
  Name:            Logitech Download Assistant
  Type:            REG_SZ
  Data:            C:\Windows\system32\rundll32.exe C:\Windows\System32\LogiLDA.dll,LogiFetch

0 个答案:

没有答案