为什么不能把2个程序都注册成随windows启动而运行?
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
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const REG_SZ = 1
Option Explicit
Private Sub cmdRegisterMyApp_Click()
Dim strKeyName As String
Dim strKeyValue As String
Dim intRet As Integer
Dim longKey As Long
strKeyName = "Software\Microsoft\Windows\CurrentVersion\Run"
strKeyValue = App.Path & "\" & "recordClient.exe"
intRet = RegCreateKey&(HKEY_LOCAL_MACHINE, strKeyName, longKey)
intRet = RegSetValue&(longKey&, "", REG_SZ, strKeyValue, 0&)
strKeyValue = App.Path & "\" & "recordClient2.exe"
intRet = RegSetValue&(longKey&, "recordClient2.exe", REG_SZ, strKeyValue, 0&)
MsgBox "registerMyApp success!"
cmdRegisterMyApp.Enabled = False
End Sub
第2个recordClient2.exe总是注册不成功,请各位指教。
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
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const REG_SZ = 1
Option Explicit
Private Sub cmdRegisterMyApp_Click()
Dim strKeyName As String
Dim strKeyValue As String
Dim intRet As Integer
Dim longKey As Long
strKeyName = "Software\Microsoft\Windows\CurrentVersion\Run"
strKeyValue = App.Path & "\" & "recordClient.exe"
intRet = RegCreateKey&(HKEY_LOCAL_MACHINE, strKeyName, longKey)
intRet = RegSetValue&(longKey&, "", REG_SZ, strKeyValue, 0&)
strKeyValue = App.Path & "\" & "recordClient2.exe"
intRet = RegSetValue&(longKey&, "recordClient2.exe", REG_SZ, strKeyValue, 0&)
MsgBox "registerMyApp success!"
cmdRegisterMyApp.Enabled = False
End Sub
第2个recordClient2.exe总是注册不成功,请各位指教。
...全文
相关推荐
Windows_Installer服务不能启动的解决方法
**所有MSI格式的程序无法正常安装**:系统可能会显示错误消息,指出无法访问Windows Installer服务,提示用户可能在安全模式下运行,或者Windows Installer未正确安装。
启动Windows程序自动运行(放入到注册表的Run)(2KB)
在Windows操作系统中,启动程序的自动化运行是一种常见的需求,特别是在系统维护、软件部署或自启动服务的场景下。
Windows开机自启动三种方式
计划任务**位置**:`控制面板` -> `管理工具` -> `任务计划程序`通过任务计划程序,可以设置在特定时间(包括系统启动时)运行程序。**操作步骤**:1. 打开任务计划程序。2.
启动Windows程序自动运行(放入到注册表的Run)(2KB)...
在Windows操作系统中,启动程序的自动化通常涉及到注册表中的“Run”键值。这个功能允许用户或系统设置在每次启动Windows时自动运行特定的应用程序或脚本。
自写把exe注册为windows服务的程序
服务控制处理程序注册后,Windows就会调用它来处理服务的生命周期事件。2. **服务控制句柄**:使用`RegisterServiceCtrlHandlerEx`函数注册服务控制处理器函数。


VB基础类
