ced55957
Messages postés108Date d'inscriptiondimanche 2 mars 2003StatutMembreDernière intervention19 juin 2012
-
6 mai 2007 à 12:19
florenth
Messages postés1023Date d'inscriptiondimanche 1 août 2004StatutMembreDernière intervention17 août 2008
-
7 mai 2007 à 12:39
bonjour bon vote a tous!
je voulais savoir si il est possible que la form1 de mon programme ne demarre qu'une seul fois a la premiere utilisation et que pa la suite le programme demarre directement su la form2??
cptpingu
Messages postés3837Date d'inscriptiondimanche 12 décembre 2004StatutModérateurDernière intervention28 mars 2023123 6 mai 2007 à 12:35
Tu dois tout simplement noter quelquepart, si l'application à déjà été démarré.
Tu peux le faire avec un simple fichier texte, un fichier ini ou écrire dans la base des registres.
Au démarrage de ton programme il te suffira de regarder si un tel marqueur est déjà présent.
cs_Loda
Messages postés814Date d'inscriptionvendredi 3 novembre 2000StatutMembreDernière intervention30 juillet 20093 6 mai 2007 à 15:08
salut,
Par exemple tu peux distribuer ton applic avec un fichier "FirstRun" dans le dossier de l'exe. et tu l'efface au first run.
En bonus, tu peux mettre le texte d'acceuil dans le fichier :-)
A+
Loda
<hr size="2" width="100%" />Se poser les bonnes questions est le premier pas pour trouver les bonnes réponses.
florenth
Messages postés1023Date d'inscriptiondimanche 1 août 2004StatutMembreDernière intervention17 août 20083 6 mai 2007 à 15:21
Ou alors, pour faire plus propre, tu essaye de créer un sémaphore au lancement de ton appli.
Si la création réussit, c'est que tu peux créer ta fichier principale, sinon, c'est l'autre !
Et c'est bien plus propre car aucun accès disque...
++
Vous n’avez pas trouvé la réponse que vous recherchez ?
uses
Forms,
uFirstRun in 'uFirstRun.pas' {FrmFirstRun},
uMain in 'uMain.pas' {FrmMain};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TFrmFirstRun, FrmFirstRun);
Application.CreateForm(TFrmMain, FrmMain);
Application.Run;
end.
bien, modifions comme cela :
program MonAppli;
uses
Forms,
uFirstRun in 'uFirstRun.pas' {FrmFirstRun},
uMain in 'uMain.pas' {FrmMain};
{$R *.res}
var FirstRun : boolean;
begin
Application.Initialize;
with TRegistry.Create do
try
RootKey := cardinal($80000001);
if OpenKey('Software\MonAppli',true) then
begin
FirstRun := not ValueExists('FirstRun');
if FirstRun then
begin
WriteInteger('FirstRun',1);
end;
end;
CloseKey;
finally
Free;
end;
case FirstRun of
true : Application.CreateForm(TFrmFirstRun, FrmFirstRun);
else
Application.CreateForm(TFrmMain, FrmMain);
end;
procedure TFrmMain.ResetFirstRun(const ByDeleteKey : boolean = false);
begin
with TRegistry.Create do
try
RootKey := HKEY_CURRENT_USER;
if ByDeleteKey then
DeleteKey('Software\MonAppli)
else
if OpenKey('Software\MonAppli',false) then
begin
DeleteValue('FirstRun');
CloseKey;
end;
finally
Free;
end;
end;
end.
et voila, au premier lancement on aurat bien la Fiche FrmFirstRun et au prochain lancement la fiche FrmMain :)
on appel la procedure :
ResetFirstRun; pour supprimer la valeur FirstRun mais pas la clef MonAppli
ResetFirstRun(true); pour supprimer la clef MonAppli
Attention, si on ajoute des fiches au projet aprés modifications on vas se retrouver avec cela dans le source du projet :
begin
Application.Initialize;
with TRegistry.Create do
try
RootKey := cardinal($80000001);
if OpenKey('Software\MonAppli',true) then
begin
FirstRun := not ValueExists('FirstRun');
if FirstRun then
begin
WriteInteger('FirstRun',1);
end;
end;
CloseKey;
finally
Free;
end;
case FirstRun of
true : Application.CreateForm(TFrmFirstRun, FrmFirstRun);
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.CreateForm(TForm3, Form3);
else
Application.CreateForm(TFrmMain, FrmMain);
end;