IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Outils Delphi Discussion :

[Inno Setup] Extraction conditionnelle de fichiers


Sujet :

Outils Delphi

  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    439
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 439
    Points : 161
    Points
    161
    Par défaut [Inno Setup] Extraction conditionnelle de fichiers
    Bonjour,

    J'ai créé un projet d'installation dont voici quelques extraits :


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    [Files]
    ;****************************** EXE ***********************************************
    Source: D:\Projet Delphi\CPS TEST\CPS.EXE; DestDir: {app}; 
    ;FS9
    Source: D:\Projet Delphi\CPS TEST\CFM.EXE; DestDir: {code:FSPath9}; 
    Source: D:\Projet Delphi\CPS TEST\CDC.EXE; DestDir: {code:FSPath9}; 
    ;FSX 
    Source: D:\Projet Delphi\CPS TEST\CFM.EXE; DestDir: {code:FSPathX}; 
    Source: D:\Projet Delphi\CPS TEST\CDC.EXE; DestDir: {code:FSPathX};
    ;P3D
    Source: D:\Projet Delphi\CPS TEST\CFM.EXE; DestDir: {code:FSPathP3D}; 
    Source: D:\Projet Delphi\CPS TEST\CDC.EXE; DestDir: {code:FSPathP3D};
    ;****************************** DLL *************************************************
    ;FS9
    Source: D:\Projet Delphi\CPS TEST\CPS.dll; DestDir:{code:FSPath9}\Modules
    ;FSX
    Source: D:\Projet Delphi\CPS TEST\CPSModulesStart.dll; DestDir:{code:FSPathX}
    ;P3D
    Source: D:\Projet Delphi\CPS TEST\CPSModulesStart.dll; DestDir:{code:FSPathP3D}
    ***********************************************************************************
    Partie code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
     
    var
       PathSim, Path : String;
     
      function FSPath9(param: string): String;
      var 
         File : TstringList;
      begin
        if (RegQueryStringValue(HKEY_CURRENT_USER, 'Software\Microsoft\Microsoft Games\Flight Simulator\9.0\', 'AppPath', PathSim))
        or (RegQueryStringValue(HKEY_CURRENT_USER, 'Software\Microsoft\Microsoft Games\Flight Simulator\9.1\', 'AppPath', PathSim)) then
        begin
          Result:= PathSim;
          Path := PathSim + '\Modules\CPS.ini';
          File := TStringList.Create;
          File.Insert(0, '[Main]');
          File.Insert(1, 'Menu0=CPS');
          File.Insert(2, '[CPS]');
          File.Insert(3, 'Caption=&CPS');
          File.Insert(4, 'Menu0=FUEL_MANAGEMENT_SHEET');
          File.Insert(5, 'Menu1=DESCENT_CALCULATOR');
          File.Insert(6, '[FUEL_MANAGEMENT_SHEET]');
          File.Insert(7, 'Open=' + ExpandConstant('{app}')+'\CFM.exe');
          File.Insert(8, '[DESCENT_CALCULATOR]');
          File.Insert(9, 'Open=' + ExpandConstant('{app}')+'\CDC.exe');
          File.SaveToFile(Path);
          File.Free; 
        end
        else
        begin
          Result:= '';
        end;
     
      end;
     
      function FSPathX(param: string): String;
      var 
         File : TstringList;
      begin
        if RegQueryStringValue(HKEY_CURRENT_USER, 'Software\Microsoft\Microsoft Games\Flight Simulator\10.0', 'AppPath',PathSim) then
        begin
          Result:= PathSim; 
          Path:= ExpandConstant('{userappdata}')+'\Microsoft\FSX\' + 'dll.xml';
          File:= TstringList.Create;
          File.LoadFromFile(Path);
          if File[7] <> '        <Name>CPS</Name>' then
          begin 
            File.SaveToFile(Path + ' before_CPS.xml');
            File.Insert(6, '    <Launch.Addon>');
            File.Insert(7, '        <Name>CPS</Name>');
            File.Insert(8, '        <Disabled>False</Disabled>');
            File.Insert(9, '        <ManualLoad>False</ManualLoad>');
            File.Insert(10, '        <Path>CPSModulesStart.dll</Path>');
            File.Insert(11, '    </Launch.Addon>');
            File.SaveToFile(Path);
            File.Free;    
          end;
        end
        else
         begin
           Result:= '';
         end; 
      end;
     
      function FSPathP3D(param: string): String;
      var 
         File : TstringList;
      begin
        if RegQueryStringValue(HKEY_CURRENT_USER, 'Software\Lockheed Martin\Prepar3D v3', 'AppPath',PathSim) then
        begin
          Result:= PathSim;
          Path:= ExpandConstant('{userappdata}')+'\Lockheed Martin\Prepar3D v3\' + 'DLL.XML';
          File:= TstringList.Create;
          File.LoadFromFile(Path);
          if File[7] <> '        <Name>CPS</Name>' then
          begin 
            File.SaveToFile(Path + ' before_CPS.xml');
            File.Insert(6, '    <Launch.Addon>');
            File.Insert(7, '        <Name>CPS</Name>');
            File.Insert(8, '        <Disabled>False</Disabled>');
            File.Insert(9, '        <ManualLoad>False</ManualLoad>');
            File.Insert(10, '        <Path>CPSModulesStart.dll</Path>');
            File.Insert(11, '    </Launch.Addon>');
            File.SaveToFile(Path);
            File.Free;  
          end;
        end
        else
        begin
          Result:= ''; 
        end;   
      end;
    Voici mon problème maintenant.

    Les utilisateurs peuvent avoir sur leur machine un ou plusieurs simulateurs (FS9/9.1, FSX ou P3D)
    Mon idée était d'installer les exécutables et une dll à des emplacements qui diffèrent selon le ou les simulateurs installés.

    Le fonctionnement est correct pour les simulateurs installés, mais lorsque l'installation de trouve pas un ou plusieurs d'entre eux sur la machine, elle installe les exécutables et la dll à la racine de C:.

    Ma question est:
    Comment éviter cette installation à la racine de C: ?

    Merci de votre aide
    Cordialement
    Pierre

  2. #2
    Rédacteur/Modérateur
    Avatar de Andnotor
    Inscrit en
    Septembre 2008
    Messages
    5 683
    Détails du profil
    Informations personnelles :
    Localisation : Autre

    Informations forums :
    Inscription : Septembre 2008
    Messages : 5 683
    Points : 13 092
    Points
    13 092
    Par défaut
    Il faut conditionner l'extraction des fichiers, commande check :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    [Files]
    Source: D:\Projet Delphi\CPS TEST\CFM.EXE; DestDir: {code:FSPath9}; check IsSim9Installed;
     
    [Code ]
    function IsSim9Installed :boolean;
    begin
      Result := RegKeyExists(HKEY_CURRENT_USER, 'Software\Microsoft\Microsoft Games\Flight Simulator');
    end;

  3. #3
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    439
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 439
    Points : 161
    Points
    161
    Par défaut
    Merci infiniment.
    Je teste.

    Cordialement
    Pierre

  4. #4
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    439
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 439
    Points : 161
    Points
    161
    Par défaut
    C'est parfait.

    Merci encore.

    Cordialement
    Pierre

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 4
    Dernier message: 26/07/2011, 17h52
  2. Réponses: 2
    Dernier message: 01/09/2010, 09h02
  3. Réponses: 8
    Dernier message: 24/05/2010, 13h03
  4. [Inno setup/IsTool]Intégrer une icône de désinstallation
    Par marsup54 dans le forum Installation, Déploiement et Sécurité
    Réponses: 1
    Dernier message: 03/01/2007, 12h05
  5. Inno Setup : Enregistrer dans la bdr le group
    Par yoghisan dans le forum Outils
    Réponses: 1
    Dernier message: 05/06/2005, 16h04

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo