贴个注册表的 Private Declare Function RegCreateKey& Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey&, ByVal lpszSubKey$, lphKey&) Private Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As LongConst HKEY_LOCAL_MACHINE = &H80000002 Const REG_SZ = 1'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run Public Function AutoRun() As Boolean '声明变量 Dim sKeyName As String, sKeyValue As String, sKeyValueIcon As String Dim Ret As Integer, lphKey As Long On Error GoTo errHandle sKeyName = "Software\Microsoft\Windows\CurrentVersion\Run" sKeyValue = "自动运行程序的完整路径和完整文件名称" Ret = RegCreateKey&(HKEY_LOCAL_MACHINE, sKeyName, lphKey) Ret = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&) AutoRun = True Exit Function errHandle: AutoRun = False End Function
将其拖到"开始"菜单的启动目录下
3.把它放到注册表里.
4.把它写到批处理文件中,让它执行,--麻烦
MICROSOFT-->WINDOWS-->CURRENTVERSION-->RUN-->右边列表:默认,右键单击->
修改->数值数据:把你要启动的程序的.exe文件在目录COPY过来.
Private Declare Function RegCreateKey& Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey&, ByVal lpszSubKey$, lphKey&)
Private Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As LongConst HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
Public Function AutoRun() As Boolean
'声明变量
Dim sKeyName As String, sKeyValue As String, sKeyValueIcon As String
Dim Ret As Integer, lphKey As Long
On Error GoTo errHandle
sKeyName = "Software\Microsoft\Windows\CurrentVersion\Run"
sKeyValue = "自动运行程序的完整路径和完整文件名称"
Ret = RegCreateKey&(HKEY_LOCAL_MACHINE, sKeyName, lphKey)
Ret = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)
AutoRun = True
Exit Function
errHandle:
AutoRun = False
End Function