Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 21-07-2005
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.114
Poder: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Hola,

A ver qué puede decirte esta "cosa" que me ha salido a bote pronto:

Código Delphi [-]
 unit UfrmPrincipal;
 
 interface
 
 uses
   Windows, Forms, SysUtils,
   Classes, Registry, Dialogs;
 
 type
   TfrmPrincipal = class(TForm)
     procedure FormCreate(Sender: TObject);
   private
     function PrimerInicio(usarRegistro: boolean) : boolean;
   public
   end;
 
 var
   frmPrincipal: TfrmPrincipal;
 
 implementation
 
 {$R *.dfm}
 
 resourcestring
   rsClaveInicio   = 'SOFTWARE\Tu programa\Inicio';
   rsArchivoInicio = 'inicio';
 
 procedure TfrmPrincipal.FormCreate(Sender: TObject);
 begin
   if PrimerInicio(false) then
   begin
     ShowMessage('Es el primer inicio del programa');
     {...}
   end
   else
   begin
     ShowMessage('NO es el primer inicio del programa');
     {...}
   end;
 end;
 
 function TfrmPrincipal.PrimerInicio(usarRegistro: boolean) : boolean;
 var
   dir: string;
   reg: TRegistry;
 begin
   if usarRegistro then
   begin
     reg := TRegistry.Create;
     try
       with reg do begin
         RootKey := HKEY_CURRENT_USER;
         Result := not KeyExists(rsClaveInicio);
         if Result then CreateKey(rsClaveInicio);
       end;
     finally
       reg.Free;
     end;
   end
   else
   begin
     dir := ExtractFilePath(ParamStr(0));
     Result := not FileExists(dir + rsArchivoInicio);
     if Result then TFileStream.Create(dir + rsArchivoInicio, fmCreate);
   end;
 end;
 
 end.
__________________
David Esperalta
www.decsoftutils.com
Responder Con Cita
  #2  
Antiguo 21-07-2005
Avatar de vtdeleon
vtdeleon vtdeleon is offline
Miembro
 
Registrado: abr 2004
Ubicación: RD & USA
Posts: 3.236
Poder: 24
vtdeleon Va por buen camino
Saludos

Una Curiosidad, Si PrimerInicio(false) le asignas falso nunca entrara a
Código Delphi [-]
 var
     dir: string;
     reg: TRegistry;
   begin
     if usarRegistro then
     begin
       reg := TRegistry.Create;
       try
         with reg do begin
           RootKey := HKEY_CURRENT_USER;
           Result := not KeyExists(rsClaveInicio);
           if Result then CreateKey(rsClaveInicio);
         end;
       finally
         reg.Free;
       end;
     end
O veo mal
__________________
Van Troi De León
(Not) Guía, Code vB:=Delphi-SQL, ¿Cómo?
Viajar en el tiempo no es teóricamente posible, pues si lo fuera, ya estarían aqui contándonos al respecto!

Última edición por vtdeleon fecha: 21-07-2005 a las 13:56:15.
Responder Con Cita
  #3  
Antiguo 21-07-2005
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.114
Poder: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Hola,

No; no ves mal vtdeleon. No entrará a lo que dices, pero para eso está lo que sigue... o sea:

Código Delphi [-]
 else // usarRegistro = false;
 begin
   dir := ExtractFilePath(ParamStr(0));
   Result := not FileExists(dir + rsArchivoInicio);
   if Result then TFileStream.Create(dir + rsArchivoInicio, fmCreate);
 end;
__________________
David Esperalta
www.decsoftutils.com
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 09:31:24.


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
Copyright 1996-2007 Club Delphi