|
' Declare API
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
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
Private Sub command1_Click()
Dim hKey As Long, SubKey As String, strExe As String, Ret As Long
hKey = &H80000001
SubKey = "software\microsoft\windows\currentversion\run"
strExe = "C:\Windows\Notepad.exe"
RegCreateKey hKey, SubKey, Ret
RegSetvalueEx Ret, "记事本", 0, 1, ByVal strExe, LenB(strExe)
RegCloseKey Ret
MsgBox strExe & " 程序已经被设定成 windows 启动时自动被执行的程序!"
End Sub
[em26] |
|