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.