自动运行: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 Form_Load()
Dim ret
Dim strPath As String
Dim strValue As String
Dim b() As BytestrPath = "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.将程序在注册表中的HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run键值下建立执行。
    2.程序中编写拷贝事件,创建快捷方式到
    C:\WINDOWS\Start Menu\Programs\启动中
    3.编写autoexec.bat文件,在其中加入程序的执行。
    4.修改win.ini文件,在[windows]下加入load项。可以装载程序。至于程序的任务栏图标事件,直接加在程序的load事件中就可以了。
      

  2.   

    将程序添加到注册表RUN就可以了