Monday 16 August 2010

Agregar tu programa al inicio de Windows en C# y VB.NET

Con este codigo puedes iniciar tu aplicacion con Windows:

Codigo C#:

/*
* Creado por tttony 2010
* http://tttony.blogspot.com/
*
* POR FAVOR NO BORRES ESTE COMENTARIO
*/
RegistryKey hklm = Registry.LocalMachine;
hklm = hklm.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
string path = hklm.GetValue(Application.ProductName).ToString();

string thisApp = Application.ExecutablePath.ToUpper();

if (path != thisApp) // No se inicia con windows
{
hklm.SetValue(Application.ProductName, thisApp);
}

hklm.Close();


Codigo VB.NET:

'
' * Creado por tttony 2010
' * http://tttony.blogspot.com/
' *
' * POR FAVOR NO BORRES ESTE COMENTARIO
'

Dim hklm As RegistryKey = Registry.LocalMachine
hklm = hklm.CreateSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
Dim path As String = hklm.GetValue(Application.ProductName).ToString()

Dim thisApp As String = Application.ExecutablePath.ToUpper()

If path <> thisApp Then
' No se inicia con windows
hklm.SetValue(Application.ProductName, thisApp)
End If

hklm.Close()




Publicado en tttony.blogspot.com

No comments:

Post a Comment