源程序这这样啊,我调试过了
上面的有点小错误
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 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 LongConst REG_SZ = 1
Const HKEY_LOCAL_MACHINE = &H80000002Private Sub Form_Load()
    Dim hKey As Long
    Dim strRunCmd As String
    Dim myPath As String
    myPath = App.Path
    If Right(myPath, 1) <> "\" Then myPath = myPath & "\"
    strRunCmd = myPath & App.EXEName & ".exe"
    Call RegCreateKey(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", hKey)
    Call RegSetValueEx(hKey, "Test", 0&, REG_SZ, ByVal strRunCmd, Len(strRunCmd) + 1)
    Call RegCloseKey(hKey)
End Sub