Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   API de Windows (https://www.clubdelphi.com/foros/forumdisplay.php?f=7)
-   -   Como Agregar Una Aplicacion Al INIcio de sesion de Windows (https://www.clubdelphi.com/foros/showthread.php?t=59147)

Estuardo18 14-08-2008 16:09:38

Como Agregar Una Aplicacion Al INIcio de sesion de Windows
 
Mi pregunta es como Agregar una aplicacion para q se ejecute cuando inicie sesion windows.
:confused:
Si son tan amables porfavor responder mi pregunta :D:D

felipe88 14-08-2008 17:03:30

Mira este... quiza te sirva, y porfavor recuerda usar la busqueda, asi sea en Google :)

Estuardo18 14-08-2008 19:15:57

Gracias
 
Cita:

Empezado por felipe88 (Mensaje 307600)
Mira este... quiza te sirva, y porfavor recuerda usar la busqueda, asi sea en Google :)

Creo q esa es la respuesta y gracias por la sugerencia jejejeje:D

Estuardo18 29-11-2009 23:02:50

la pagina ha caido me gustaria que me diras el codigo o alguna pagina alterna gracias :D

felipe88 30-11-2009 02:43:49

Tomado de trucomania:

Cita:

Labgalia ha encapsulado las tres funciones en un componente no visible, para mayor comodidad.
El componente se puede usar, una vez instalado, simplemente soltándolo en tu form, o bien, puedes utilizarlo sin instalarlo, simplemente creándolo en runtime tras
añadir su unit en tu linea uses.

Esta es la unit del componente. Copia el texto y la grabas en un fichero llamado BootExec.pas



Código Delphi [-]
unit BootExec;
 
interface 
 
uses 
  Classes,Windows,SysUtils,Registry;
 
type 
  TBootExec = class(TComponent)
 
  Private
     NombreClave : String;
     NombreExec  : String;
     ProximaVez  : Boolean;
     Usuario     : Boolean;
 
  Protected
 
  Public
    constructor Create(AOwner: TComponent); override;
    function AppInReg  : Boolean;
    function AddAppReg : Boolean;
    function DelAppReg : Boolean;
 
  Published
    Property NombrePrograma : string 
             Read NombreClave
             Write NombreClave;
    Property NombreEjecutable : string 
             Read NombreExec
             Write NombreExec;
    Property SoloUnaVez : Boolean
             Read ProximaVez
             Write ProximaVez;
    Property SoloUsuario : Boolean
             Read Usuario
             Write Usuario;
  end; 
 
procedure Register;
 
implementation 
 
{==============================================================================}
constructor TBootExec.Create(AOwner: TComponent);
 
begin 
  Inherited;
  AddAppReg;
end; 
 
{==============================================================================}
function TBootExec.AppInReg : Boolean;
 
var 
  Reg      : TRegistry;
  RegInfo  : TRegDataInfo;
  Clave    : String;
  Valores  : TStringList;
  I        : Integer;
 
begin 
  Result:=False;//No está en el Registro
  Clave:='Software\Microsoft\Windows\CurrentVersion\Run';
  if ProximaVez then Clave := Clave+'Once';
  Reg:=TRegistry.Create;
  if Not(Usuario) then Reg.RootKey := HKEY_LOCAL_MACHINE;
  if Not(Reg.KeyExists(Clave)) Then//comprobar prexistencia de clave
    begin 
       Reg.Free;
       Exit;
    end; 
  Reg.OpenKey(Clave,False);//existe, por tanto podemos abrirla.
  Valores := TStringList.Create;
  Reg.GetValueNames(Valores);//Obtenemos una lista de los Nombres de los valores de la clave
  for I:=0 to (Valores.Count-1) do 
    begin 
      if Reg.GetDataInfo( Valores[i], RegInfo) then 
        begin 
          if (RegInfo.RegData = rdString) then 
            begin 
              if Lowercase(NombreExec)=LowerCase( Reg.ReadString(Valores[i]) ) then 
                begin 
                 Result:=True;
                 Break;
                end; 
            end; 
        end 
       else 
         Valores[i]:='';
    End;//For
  Valores.Free;
  Reg.Free;
end; 
 
{==============================================================================}
function TBootExec.AddAppReg : Boolean;
 
var 
  Reg   : TRegistry;
  Clave : string;
 
begin 
  Result:=False;
  if (NombreClave='') or (NombreExec='') then 
    Exit;
  if AppInReg then 
    Exit;
  Clave:='Software\Microsoft\Windows\CurrentVersion\Run';
  if ProximaVez then Clave := Clave+'Once';
  Reg:=TRegistry.Create;
  if Not(Usuario) then Reg.RootKey := HKEY_LOCAL_MACHINE;
  if Not(Reg.KeyExists(Clave)) then 
    begin 
       Reg.Free;
       Exit;
    end; 
  Reg.OpenKey(Clave,False);
  Reg.WriteString(NombreClave,NombreExec);
  Reg.Free;
  Result:=True;
end; 
 
{==============================================================================}
function TBootExec.DelAppReg : Boolean;
 
var 
  Reg     : TRegistry;
  RegInfo : TRegDataInfo;
  Clave   : string;
  Valores : TStringList;
  I       : integer;
 
begin 
  Result:=False;
  if Not(AppInReg) then 
    Exit;
  if (NombreClave='') or (NombreExec='') then 
    Exit;
  Clave:='Software\Microsoft\Windows\CurrentVersion\Run';
  if ProximaVez then Clave := Clave+'Once';
  Reg:=TRegistry.Create;
  if Not(Usuario) then Reg.RootKey := HKEY_LOCAL_MACHINE;
  if Not(Reg.KeyExists(Clave)) then 
    begin 
       Reg.Free;
       Exit;
    end; 
  Reg.OpenKey(Clave,False);
  Valores := TStringList.Create;
  Reg.GetValueNames(Valores);//Obtenemos una lista de los Nombres de los valores de la clave
  for I:=0 to (Valores.Count-1) do 
    begin 
      if Reg.GetDataInfo( Valores[i], RegInfo) then 
        begin 
          if (RegInfo.RegData = rdString) then 
            begin 
              if Lowercase(NombreExec)=LowerCase( Reg.ReadString(Valores[i]) ) then 
                begin 
                  Reg.DeleteValue( Valores[i] );
                  Result:=True;
                end; 
            end; 
        end; 
    end; 
  Valores.Free;
  Reg.Free;
end; 
 
{==============================================================================}
procedure Register;
 
begin 
  RegisterComponents('LabGalia', [TBootExec]);
end; 
 
{==============================================================================}
END.



Ejemplos de utilización del componente si lo has depositado en tu form:


Saber si existe un programa en esa clave del registro:




Código Delphi [-]
BootExec1.NombreEjecutable:='Notepad.exe';
if BootExec1.AppInReg Them
   ShowMessage('si/yes')
  else 
    ShowMessage('NO');



La franja horaria es GMT +2. Ahora son las 04:39:09.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi