اجرای خورکار | ویژوال بیسیک | VB
شاید شما دوست داشته باشید که برنامه ای که توسط vb ایجاد کردید زمان اجرا ویندوز بصورت خودکار اجرا بشه برای این کار از کد زیر استفاده کنید.
| 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 = "MySampleApplication" Dim KeyValue As String = "C:\test\test.exe" regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True) If regKey.GetValue(KeyName) = Nothing Then 'if there's no KeyName yet? then create and set it's value MsgBox("No Program of this name found..!") regKey.SetValue(KeyName, KeyValue, Microsoft.Win32.RegistryValueKind.String) MsgBox("key " & KeyName & " has been created") End If End Sub End Class |
منبع:www.cesblog.ir
+ نوشته شده توسط CES در جمعه بیستم خرداد ۱۳۹۰ و ساعت
19:42 |
