贴个注册表的
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 Long
'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