1

我在这里有这个函数来检查它是否在注册表中,如果是则返回 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
4

0 回答 0