设置程序随windows系统启动,其实就是就是将程序加载到注册表
Public Sub StartRunRegHKLM() REM HKEY_LOCAL_MACHINE \ SOFTWARE \ WOW6432Node \ Microsoft \ Windows \ CurrentVersion \ Run Dim strName As String = Application.StartupPath + "\" + Application.ProductName + ".exe" Dim strNewName As String = System.IO.Path.GetFileNameWithoutExtension(strName) If Not System.IO.File.Exists(strName) Then Return Try Dim Rkey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run", True) If IsNothing(Rkey) Then Rkey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run") Rkey.SetValue(strNewName, Chr(34) & strName & Chr(34)) '修改注册表,使程序开机时自动执行. Else Rkey.SetValue(strNewName, Chr(34) & strName & Chr(34)) '修改注册表,使程序开机时自动执行。 End If Catch ex As Exception MessageBox.Show(ex.Message, "StartRun") ' //MessageBox.Show(ex.Message); End Try End Sub