Astrog (Normal User)
Newbie
Messaggi: 11
Iscritto: 31/05/2010
|
salve a tutti, sto creando un programma e tra le opzioni vorrei mettere la possibilità di aprirlo automaticamente all'apertura di windows come vediamo in tanti programmi.
girando un po in internet ho trovato una discussione che diceva di creare una chiave di registro sotto la voce HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
studiando un po ho capito come creare delle chiavi di registro e mi è uscita fuori una cosa del genere che però non sembra creare propio nulla:
Codice sorgente - presumibilmente VB.NET |
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim SOFTWARE As RegistryKey = _ Registry.LocalMachine.CreateSubKey("SOFTWARE") Dim Microsoft As RegistryKey = _ SOFTWARE.CreateSubKey("MICROSOFT") Dim Windows As RegistryKey = _ SOFTWARE.CreateSubKey("Windows") Dim CurrentVersion As RegistryKey = _ Windows.CreateSubKey("CurrentVersion") Dim Run As RegistryKey = _ CurrentVersion.CreateSubKey("Run") ' Create data for the TestSettings subkey. Run.SetValue("Nome", Application.ExecutablePath) End Sub
|
sono ben accette altre soluzioni oltre all'inserimento di una chiave di registro anche se ormai non mi dispiacerebbe approfondire l'argomento
grazie mille per il vostro aiuto
Ultima modifica effettuata da Astrog il 27/03/2012 alle 21:59 |
|
GrG (Member)
Guru^2
Messaggi: 3430
Iscritto: 21/08/2007
|
usa e studia queste due sub già fatte:
Codice sorgente - presumibilmente VB.NET |
Public Sub RunAtStartup(ByVal ApplicationName As String, ByVal ApplicationPath As String) Dim CurrentUserRun As Microsoft.Win32.RegistryKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run") With CurrentUserRun .OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True) .SetValue(ApplicationName, ApplicationPath) End With End Sub Public Sub RemoveFromStartup(ByVal ApplicationName As String) Dim CurrentUserRun As Microsoft.Win32.RegistryKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run") With CurrentUserRun .OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True) .DeleteValue(ApplicationName, False) End With End Sub
|
|
|
GN (Member)
Guru
Messaggi: 772
Iscritto: 30/04/2011
|
|
|