开机启动的程序如何编写?
编写了一个小程序,想让他在开机时自己启动,请问这个程序如何编写,谢谢了!
Option Explicit
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (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 Const HKEY_LOCAL_MACHINE = &H80000002
Private Const REG_SZ = 1
Private Sub Command1_Click()
Dim hReg As Long, value As String
value = "f:\aaa.exe"
RegOpenKey HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", hReg
RegSetValueEx hReg, "自己的程序", ByVal 0&, REG_SZ, ByVal CStr(value), LenB(StrConv(value, vbFromUnicode)) + 1
End Sub