Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C# / VB.NET - Programma che si apre all'avvio di windows
Forum - C# / VB.NET - Programma che si apre all'avvio di windows

Avatar
Astrog (Normal User)
Newbie


Messaggi: 11
Iscritto: 31/05/2010

Segnala al moderatore
Postato alle 21:57
Martedì, 27/03/2012
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

  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.  
  3.         Dim SOFTWARE As RegistryKey = _
  4.             Registry.LocalMachine.CreateSubKey("SOFTWARE")
  5.  
  6.  
  7.         Dim Microsoft As RegistryKey = _
  8.             SOFTWARE.CreateSubKey("MICROSOFT")
  9.         Dim Windows As RegistryKey = _
  10.            SOFTWARE.CreateSubKey("Windows")
  11.         Dim CurrentVersion As RegistryKey = _
  12.             Windows.CreateSubKey("CurrentVersion")
  13.         Dim Run As RegistryKey = _
  14.             CurrentVersion.CreateSubKey("Run")
  15.  
  16.  
  17.         ' Create data for the TestSettings subkey.
  18.  
  19.  
  20.         Run.SetValue("Nome", Application.ExecutablePath)
  21.     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
PM
Avatar
GrG (Member)
Guru^2


Messaggi: 3430
Iscritto: 21/08/2007

Up
1
Down
V
Segnala al moderatore
Postato alle 22:04
Martedì, 27/03/2012
usa e studia queste due sub già fatte:

Codice sorgente - presumibilmente VB.NET

  1. Public Sub RunAtStartup(ByVal ApplicationName As String, ByVal ApplicationPath As String)
  2.         Dim CurrentUserRun As Microsoft.Win32.RegistryKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
  3.         With CurrentUserRun
  4.             .OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
  5.             .SetValue(ApplicationName, ApplicationPath)
  6.         End With
  7.     End Sub
  8.  
  9.     Public Sub RemoveFromStartup(ByVal ApplicationName As String)
  10.         Dim CurrentUserRun As Microsoft.Win32.RegistryKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
  11.         With CurrentUserRun
  12.             .OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
  13.             .DeleteValue(ApplicationName, False)
  14.         End With
  15.     End Sub



:k:

grazie mille per la tua rapida risposta, avevo provato con un sistema molto simile però anche questo non sembra fare nulla, non capisco davvero dove sia il problema - Astrog - 27/03/12 22:16
eppure non aprendo il compilatore con i diritti di amministratore mi da un errore dicendo che non ho i privilegi per scrivere nelle chiavi di registro... - Astrog - 27/03/12 22:23
E' corretto che, non essendo amministratore, non scrivi in quelle chiavi ... è una protezione contro i virus ... - nessuno - 28/03/12 10:18
PM
Avatar
GN (Member)
Guru


Messaggi: 772
Iscritto: 30/04/2011

Up
1
Down
V
Segnala al moderatore
Postato alle 22:07
Martedì, 27/03/2012
Qui dovrebbe esserci dell'ottimo materiale sulla modifica del registro http://totemslair.org/guide/viewchapter.php?guida=vb&id=85

PM