软件随着windows启动的vb代码?

来源:百度知道 编辑:UC知道 时间:2024/09/18 05:12:14

如果是是调用其他的程序启动。
新建工程。添加三个CommandButton控件,一个TextBox控件 一个CommonDialog控件
代码如下:
Option Explicit
Const REG_SZ As Long = 1
Const HKEY_LOCAL_MACHINE = &H80000002

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 Form_Load()
Text1.Text = App.Path & "\选择要设置程序自动开机启动.exe"
End Sub

Private Sub Command1_Click()
Dim hKey As Long
Dim myexe As String
Dim myint As Integer
myint = Len(Text1.Text) - InStr