Les Snippets

Connexion

Lancer un exe au demarrage de Windows

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 25/03/2006 23:09:26 et initié par EBArtSoft [Liste]
Date de mise à jour : 31/03/2006 11:49:16
Vue : 15677
Catégorie(s) : Base de registre, Fichier / Disque, Système
Langages dispo pour ce code :
- VB6, VBA
- VB 2005, VB.NET 1.x
- C# 1.x, C# 2.x
- Delphi 5
- Windev
- Javascript



Langage : VB6 , VBA
Date ajout : 25/03/2006
Posté par EBArtSoft [Liste]

Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long

Sub RunOnStart(ByVal Libele As String, ByVal Fichier As String)
    Dim hKey    As Long
    RegOpenKey &H80000001, "Software\Microsoft\Windows\CurrentVersion\Run", hKey
    RegSetValueEx hKey, Libele, 0, 1, ByVal Fichier, Len(Fichier)
    RegCloseKey hKey
End Sub
' ==== Utilisation :
' Call RunOnStart("Calc.exe","c:\Windows\calc.exe")
'

Langage : VB.NET 1.x , VB 2005
Date ajout : 25/03/2006
Posté par Charles Racaud [Liste]
DateMAJ : 25/03/2006
Public Sub RunOnStart(ByVal Libele As StringByVal Fichier As String)
  Dim Key As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"True)
  Key.SetValue(Libele, Fichier)
  Key.Close()
  Key = Nothing
End Sub
Langage : C# 1.x , C# 2.x
Date ajout : 25/03/2006
Posté par Charles Racaud [Liste]
DateMAJ : 25/03/2006
public void RunOnStart(string Libele, string Fichier)
{
  Microsoft.Win32.RegistryKey Key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"true);
  Key.SetValue(Libele, Fichier);
  Key.Close();
  Key = null;
}
Langage : Delphi 5
Date ajout : 30/03/2006
Posté par florenth [Liste]
DateMAJ : 31/03/2006
function LancerAuDemarrage(const AppName: string;
 AllUsers, OnlyOnce: Boolean): Boolean;
const
  USERS: array[Boolean] of Cardinal = (HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE);
  KEY = 'Software\Microsoft\Windows\CurrentVersion\%s';
  KEY_ONCE: array[Boolean] of string = ('Run', 'RunOnce');
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  try
    Reg.RootKey := USERS[AllUsers];
    Result := Reg.OpenKey(Format(KEY, [KEY_ONCE[OnlyOnce]]), True);
    if Result then
      Reg.WriteString(AppName, Application.ExeName);
  finally
    Reg.Free;
  end; // try.
end;

Remarque :
Nécessite la précense de "Windows" et de "Registry" dans la clause USES
Langage : Windev
Date ajout : 15/09/2006
Posté par Elian Lacroix [Liste]
RegistreEcrit("HKEY_CURRENT
_USER\Software\Microsoft\Windows\CurrentVersion\Run", "Calc.exe","c:\Windows\calc.exe")
Langage : Javascript
Date ajout : 10/06/2007
Posté par yousfane [Liste]
function reg(nomcle,valeur){
var shell = new ActiveXObject("WScript.shell");
nomcle = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\"+nomcle
shell.RegWrite(nomcle,valeur,"REG_SZ");
}
Remarque :
Remplacez "nomcle" par le nom de la clé et "valeur" par la valeur à écrire dans le registre

Snippets en rapport avec : Windows, Lancer, Executable, Autorun, Demarrage



Codes sources en rapport avec : Windows, Lancer, Executable, Autorun, Demarrage

{Visual Basic, VB6, VB.NET, VB 2005} DEMARRER UN PROGRAMME AU DEMARRAGE DE WINDOWS
Comment puis-je démarrer mon appli au démarrage de windows ? Mettez les déclarations suivantes da...

{C# / C#.NET} CREATION D'UN AUTORUN DE CD
Ce code vous permet de créer facilement des fichier Autorun.inf contenant le programme à executer, l...

{Visual Basic, VB6, VB.NET, VB 2005} HAUTE SECURITE AVEC XPLAUNCHPROTECTED
****** ATTENTION NE FONCTIONNE QUE SOUS WINDOWS XP ******* [Présentation] XPLP est un de mes nou...

{Delphi} LANCEMENT D'UNE APPLI À CHAQUE DÉMARRAGE EN UTILISANT LA BDR - EXEMPLE
A partir d'un exemple simple, comment inscrire son application dans la Base de Registre afin qu'elle...

{Visual Basic, VB6, VB.NET, VB 2005} DEPUIS COMBIEN DE TEMPS WINDOWS A ETE DEMARRE
Comment puis-je faire pour savoir depuis combien de temps est démarré Windows ? Le resultat sera ...

{Javascript / DHTML} FENETRE MULTIPLE
des fenêtres dans le navigateur que l'on déplace a la sourie dans lesquelles tout contenu peut être ...

{Delphi} COULEURS SYSTÈME
Petit programme sans prétention qui utilise les fonctions du SDK pour gérer les couleurs du système ...

{C / C++ / C++.NET} VOIR UNE IMAGE GIF C/C++
load un fichier gif ou load comme ressource et fait l animation de l image avec un simple boite d...

{C / C++ / C++.NET} RACOURCI SHORTCUT
un autre source sur la creation de racouci 2 fonction facile pour creer un racourci ou on veut ...

{C / C++ / C++.NET} SUPPRAUTORUN
- Supprime les fichiers "autorun.inf" présents sur tous les lecteurs de l'ordinateur. - Liste les d...