Vous pouvez utiliser la propriété WizardForm.PrevAppDir
, qui détient le chemin du dossier, où le programme d'installation avec un certain AppId
avait déjà installé l'application (vide si elle n'a pas été encore installé). Notez que cette propriété est remplie après l'initialisation du formulaire de l'assistant, donc lisez-la après l'événement InitializeWizard
.
Pour votre tâche, je ferais cette opération à l'étape de pré-installation, donc pour la méthode d'événement CurStepChanged
, je voudrais écrire quelque chose comme:
[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
DataFilePath: string;
begin
// check if the current step is pre-installation step and if the
// application had been previously installed; if so, then...
if (CurStep = ssInstall) and (WizardForm.PrevAppDir <> '') then
begin
// build and store the path to the Data.mpd file from the prev.
// installation path
DataFilePath := AddBackslash(WizardForm.PrevAppDir) + 'Data.mpd';
// check, if that Data.mpd file exists; if so, then...
if FileExists(DataFilePath) then
// copy it to the target directory; if it fails, show error message
if not FileCopy(DataFilePath, <your new directory here>, False) then
MsgBox('Copying of the Data.mpd failed!', mbError, MB_OK);
end;
end;
Si je comprends bien, vous voulez obtenir le chemin de l'installation précédente de votre application, vérifiez s'il y a le fichier 'data.mpd' et copiez ce fichier dans le dossier' C: \ Users \ .. ', Est-ce correct ? – TLama
Oui ... Le point est qu'il peut être situé à C: \ ProgramFiles (comme c'est le répertoire par défaut proposé par l'InnoSetup) mais ce n'est pas garanti (l'utilisateur aurait pu changer le répertoire par défaut) ... – TGMDev