Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, lpData As Byte, lpcbData As Long) As Long
Private Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As String, lpcbClass As Long, lpftLastWriteTime As Any) As Long

Private Enum RegHKey
    hkRoot = &H80000000
    hkUser = &H80000001
    hkMachine = &H80000002
    hkUsers = &H80000003
    hkPerformanceData = &H80000004
    hkConfig = &H80000005
    hkDYNData = &H80000006
End Enum

Private Function EnumValues(ByVal strKey As String, strValue() As String, Optional ByVal hKey As RegHKey = hkMachine) As Long
    Dim Ret As Long, tmpValue As String
    Dim intZeroPos As Integer, Cnt As Long

    RegOpenKey hKey, strKey, Ret
    Cnt = 0
    Do
        tmpValue = String(255, Chr$(0))
        If RegEnumValue(Ret, Cnt, tmpValue, 255, 0, ByVal 0&, ByVal 0&, ByVal 0&) <> 0 Then Exit Do
        ReDim Preserve strValue(Cnt) As String
        intZeroPos = InStr(1, tmpValue, Chr$(0))
        strValue(Cnt) = IIf(intZeroPos > 0, Left$(tmpValue, intZeroPos - 1), tmpValue)
        Cnt = Cnt + 1
    Loop

    RegCloseKey Ret
    EnumValues = Cnt
End Function

'测试项目为系统启动项:

Private Sub Form_Load()
    Dim strValue() As String
    Dim i As Long
    For i = 0 To EnumValues("Software\Microsoft\Windows\CurrentVersion\Run", strValue) - 1
        Debug.Print strValue(i)
    Next i
End Sub