NT启动项的键值与98十分类似,但不记得是否完全一样,你打开看一下不就知道了吗?

解决方案 »

  1.   

    试试这个函数:
    Option ExplicitDeclare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hkey As Long) As Long
    Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hkey As Long, ByVal lpSubKey As String) As Long
    Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
    Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
    Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hkey As Long, ByVal lpValueName As String) As LongPublic Const REG_SZ = 1
    Public Const REG_DWORD = 4
    Public Const HKEY_CURRENT_USER = &H80000001
    Public Const HKEY_LOCAL_MACHINE = &H80000002Dim hkey As Long 'key's handle
    Dim rtn As Long, lValueType As Long, lDataBufSize As Long, strBuf As StringFunction GetStringValue(ByVal MainKeyHandle As Long, ByVal Subkey As String, strValueName As String) As String
    'Get string value from registry.Return a value string or a nullchar
    rtn = RegOpenKey(MainKeyHandle, Subkey, hkey) 'open the key
    If rtn <> 0 Then GetStringValue = vbNullChar: Exit Function 'if the key not exists
        'get information about the key
        rtn = RegQueryValueEx(hkey, strValueName, 0, lValueType, ByVal 0, lDataBufSize)
        If rtn = 0 And lValueType = REG_SZ Then
            strBuf = String(lDataBufSize, Chr(0)) 'Create a buffer
            'retrieve the key's content
            rtn = RegQueryValueEx(hkey, strValueName, 0, 0, ByVal strBuf, lDataBufSize)
            GetStringValue = Left(strBuf, InStr(1, strBuf, Chr(0)) - 1)
        Else
            GetStringValue = vbNullChar
        End If
    RegCloseKey hkey
    End Function
    用的时候:text1.text=GetStringValue(HKEY_CURRENT_USER,"Software\Microsoft\Windows\CurrentVersion\Run","internat.exe")