我想用VB返回注册表的启动项。代码是这么写的:
Option Explicit
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult 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 Const HKEY_LOCAL_MACHINE = &H80000002
Private Sub Command1_Click()
    Dim hKey As Long
    Dim ret As Long
    Dim myIndex As Long
    Dim strKeyName As String
    Dim rc As Long
    Dim bValue As Byte
    strKeyName = Space(1024)
    myIndex = 0
    ret = RegCreateKey(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", hKey)
    While ret = 0
        ret = RegEnumValue(hKey, myIndex, ByVal strKeyName, 1024, 0, 1, ByVal bValue, 1024)
        myIndex = myIndex + 1
        List.AddItem (strKeyName)
    Wend
    ret = RegCloseKey(hKey)
End Sub这段代码在VB环境下没问题,但生成EXE文件后就出错了,不能用!我错在哪呢?求大家帮忙!谢谢。