这个自己写吧,给你个思路:
用vb编写一段修改注册表的语句,将所要随机启动的程序写到注册表中就行啦。
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 lpSubKey As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Sub Form_Load()
Dim A1 As String, hKey As Long
RegCreateKey HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", hKey
A1 = App.Path & IIf(Len(App.Path) = 3, "", "\") & App.EXEName & ".exe"
RegSetValueEx hKey, "MyStartUp", 0&, REG_SZ, A1, 2 * Len(A1)
RegCloseKey HKEY_LOCAL_MACHINE
End Sub
这个是VB的版本,无需加入其他东西,其中MyStartUp为注册表键的名称,任意数值。重要的是那个路径,就是你程序的运行路径。
请看我的空间中的《开机自动启动程序》文章:
http://hi.baidu.com/xnzhrx/blog/item/20622d26039632018b82a129.html
自动启动,不是程序本身的功能。是系统的功能。
比如可以在注册表的启动项中把程序加进去。
也可以把程序作为服务,自动运行。
都可以的。
在菜单中选择【工程 => 引用】,选中windows script host object model (ver 1.0)
在程序中加入如下代码Set WSH = CreateObject("WScript.Shell")
WSH.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\名称", "文件路径", "REG_SZ"