vb如何把软件写入注册表从而开机启动

来源:百度知道 编辑:UC知道 时间:2024/07/04 10:25:26
用vb编软件,如何使软件写入注册表从而能够开机启动呢???(急用)
麻烦下能加上注释么?我是个新入门的...请多多指教...谢了

Private Sub Form_Load()
Set my = CreateObject("WScript.Shell")
my.regWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\123", dirwin & "d:\123.exe", "REG_SZ"
End Sub

楼上的可以达到你的要求,如果你每次运行都会增加的话就会有问题了,它提示已经存在的,所以最好先读取一下有没有该启动项,如果没有就加上....这样才完美
我下面这个是这个类型,你参照楼上给的地方改一下就可以了,我就不改了咯
Dim mypcname, reg As String
'Set xx = CreateObject("Wscript.shell")
'mypcname = xx.regread("HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R16.1\ACAD-301:804\Profiles\<<未命名配置>>\General\ACAD")
'If InStr(1, App.Path, mypcname) = 0 Then
'reg = App.Path & "\block_gate;" & mypcname
' xx.regwrite ("HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R16.1\ACAD-301:804\Profiles\<<未命名配置>>\General\ACAD"), reg
'End If