你要的是不是一开机自动运行.exe啊?请看下面开机自动运行代码
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''模塊
'Modul31
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public 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.
Public Const HKEY_CURRENT_USER = &H80000001
Public Const REG_SZ = 1
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''from
程序說明:
要使程序每次啟動時自動運行可以在注冊表文件
'
﹛HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run寫入啟動信息,這樣在Windows每次啟動時都會自動運行
'
﹛使用 RegCreateKey 取的HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run 的 hKey 的值既你所名的名稱
'
﹛使用 RegSetValueEx 在 hKey 下寫入一個以"我的記事本"作為名,以 "Notepad.exe"作為值的啟動
'
所有控件:
'
'Command1
'Command2
'
程序代碼:
'Form1
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command1_Click()
Dim SubKey As String
Dim Exe As String
Dim hKey As Long
SubKey = "Software\Microsoft\Windows\CurrentVersion\Run"
Exe = "Notepad.exe" '你所要啟動的項目
RegCreateKey HKEY_CURRENT_USER, SubKey, hKey
RegSetValueEx hKey, "我的記事本", 0, REG_SZ, ByVal Exe, LenB(StrConv(Exe, vbFromUnicode)) + 1
RegCloseKey hKey
End Sub