源程序这这样啊,我调试过了
上面的有点小错误
Option Explicit'读写注册表
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 LongConst REG_SZ = 1
Const HKEY_LOCAL_MACHINE = &H80000002Private Sub Form_Load()
Dim hKey As Long
Dim strRunCmd As String
Dim myPath As String
myPath = App.Path
If Right(myPath, 1) <> "\" Then myPath = myPath & "\"
strRunCmd = myPath & App.EXEName & ".exe"
Call RegCreateKey(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", hKey)
Call RegSetValueEx(hKey, "Test", 0&, REG_SZ, ByVal strRunCmd, Len(strRunCmd) + 1)
Call RegCloseKey(hKey)
End Sub
上面的有点小错误
Option Explicit'读写注册表
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 LongConst REG_SZ = 1
Const HKEY_LOCAL_MACHINE = &H80000002Private Sub Form_Load()
Dim hKey As Long
Dim strRunCmd As String
Dim myPath As String
myPath = App.Path
If Right(myPath, 1) <> "\" Then myPath = myPath & "\"
strRunCmd = myPath & App.EXEName & ".exe"
Call RegCreateKey(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", hKey)
Call RegSetValueEx(hKey, "Test", 0&, REG_SZ, ByVal strRunCmd, Len(strRunCmd) + 1)
Call RegCloseKey(hKey)
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货