السلام عليكم ورحمة الله وبركاته
مثالين لوضع البرنامج في بدء التشغيل
المثال الاول
كود :
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim regKey As Microsoft.Win32.RegistryKey
Dim KeyName As String = "test"
Dim KeyValue As String = "C:\test.exe"
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
If regKey.GetValue(KeyName) = Nothing Then
MsgBox("no value found")
regKey.SetValue(KeyName, KeyValue, Microsoft.Win32.RegistryValueKind.String)
MsgBox("key" & KeyName & "has been created")
Else
MsgBox("this programm already exists ", vbInformation, "Information")
End If
End Sub
End Class
المثال الثاني
كود :
Imports Microsoft.Win32
كود :
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
regKey.SetValue("MyExecutable", "C:\MyExecutable.exe")
regKey.Close()
End Sub
End Class