Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1 ' Unicode nul terminated string
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 Long ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As LongPrivate Sub 按钮_click()
Dim ret
Dim strPath As String
Dim strValue As String
Dim b() As Byte
在HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run先建立一个键值,值为你程序的文件名strPath = "software\microsoft\windows\currentversion\run"
strValue = "1980GAOBO"
strdata = "f:\1980gaobo.exe" & vbNullChar
b = StrConv(strdata, vbFromUnicode)
RegCreateKey HKEY_LOCAL_MACHINE, strPath, ret
length = UBound(b) + 1
RegSetValueEx ret, strValue, 0, REG_SZ, b(0), length
RegCloseKey ret
End Sub

解决方案 »

  1.   

    1.计划任务中添加。
    2.注册表中添加。(HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run)
      

  2.   

    在autoexec.bat文件(c盘跟目录下)也可以
      

  3.   

    totobi(候候) 的代码是完全可行的,我也那样子作过.
    要是还不明白,就留下E-mail,发代码给你
      

  4.   

    将你的信息加到win.exe文件的外壳上,内部调用更名的win.exe,
    从而启动你的程序。