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

API, COM et SDKs Delphi Discussion :

Dump Chm , Hlp


Sujet :

API, COM et SDKs Delphi

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Inscrit en
    Avril 2004
    Messages
    34
    Détails du profil
    Informations forums :
    Inscription : Avril 2004
    Messages : 34
    Par défaut Dump Chm , Hlp
    Salut , Comment on peux extraire le(s) contenus des Fichiers type : Chm et Hlp et sauver (le contenue ) dans une repertoire .

    J'ai trouvé une source ( dans l'attachment ) peuvant dumper le Contenue en utilisant l'IStorage mais pas de possiblité pour sauver le contenue .

    Qlq'un peux m'aider a faire exporter - sauver - le contenue SVP ?


    Merçi
    Fichiers attachés Fichiers attachés

  2. #2
    Membre émérite
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    409
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 409
    Par défaut
    pour les fichiers chm utilise Html Help WorkShop dans le menu File tu as une option Décompile, pour les hlp tu as helpdeco

  3. #3
    Membre averti
    Inscrit en
    Avril 2004
    Messages
    34
    Détails du profil
    Informations forums :
    Inscription : Avril 2004
    Messages : 34
    Par défaut
    Merçi exoseven . est-ce helpdeco Delphi ???

  4. #4
    Membre émérite
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    409
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 409
    Par défaut
    je ne suis pas sur de comprendre ... si tu veux savoir si HelpDeco est programmé avec Delphi la réponse est non, il est en C tu as d'ailleurs les sources dans le lien indiqué

  5. #5
    Expert éminent
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    14 081
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 14 081
    Par défaut
    Avec SevenZip
    un petit clic droit, 7-Zip, sous menu, Extraire ... et pouf tu as tout le projet ... tu peux le faire par ligne de commande avec les options x, -r et -o
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

  6. #6
    Membre averti
    Inscrit en
    Avril 2004
    Messages
    34
    Détails du profil
    Informations forums :
    Inscription : Avril 2004
    Messages : 34
    Par défaut
    Je l'ai fait , maintenant je peux exporter les Elements du IStorage , mais pourqoui c'est pas possible pour les SubStorage ( images , JSripts .... ).

    Le code pour l'exportation du IStorage :

    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
     
    procedure ExportStgElemets(const Source, DstDir: String);
    var
      ITS: IITStorage;
      Root: IStorage;
      Enumerator: IEnumStatStg;
      Stat: TStatStg;
      Src, Dst: IStream;
      FileStream: TFileStream;
      S: WideString;
      BytesRead, BytesWritten: Int64;
      SubStorage: IStorage;
    begin
      { Create target directory }
      ForceDirectories(DstDir);
     
      { Open Source file }
      ITS := CoITStorage.Create;
      S := ArchiveFilename;
      OleCheck(ITS.StgOpenStorage(PWideChar(S),nil,
        STGM_READ or STGM_SHARE_DENY_WRITE,nil,0,Root));
     
      { Enumerate streams in storage }
      OleCheck(Root.EnumElements(0,nil,0,Enumerator));
      while Enumerator.Next(1,Stat,nil) = S_OK do begin
        if Stat.dwType = STGTY_STORAGE then  begin
     
    OleCheck( Root.OpenStorage(Stat.pwcsName,nil,
            STGM_READ or STGM_DIRECT or STGM_SHARE_EXCLUSIVE,nil,0,SubStorage)) ;
     
       {* Pourqoui pas les SubStorage *}
     
       end
     
        else begin
     
     
          { Open source stream in storage }
          OleCheck(Root.OpenStream(Stat.pwcsName,nil,
            STGM_READ or STGM_SHARE_DENY_WRITE,0,Src));
     
     
          FileStream := TFileStream.Create(DstDir + Stat.pwcsName,fmCreate);
          Dst := TStreamAdapter.Create(FileStream,soOwned);
     
          { Copy source to destination }
          OleCheck(Src.CopyTo(Dst,Stat.cbSize,BytesRead,BytesWritten));
        end;
      end;
     
     
    end;
    Usage :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    procedure TFrmMain.Button1Click(Sender: TObject);
    begin
    ExportStgElemets(EditHelpFile.Text,'C:\test\');
    end;
    Pourqoui c'est la procedure peux pas Expoerter les SubStorage ???

    Merçi .

  7. #7
    Membre éclairé
    Homme Profil pro
    Enseignant
    Inscrit en
    Août 2008
    Messages
    668
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Août 2008
    Messages : 668
    Par défaut
    Citation Envoyé par mohfa2001 Voir le message
    Salut , Comment on peux extraire le(s) contenus des Fichiers type : Chm et Hlp et sauver (le contenue ) dans une repertoire .

    J'ai trouvé une source ( dans l'attachment ) peuvant dumper le Contenue en utilisant l'IStorage mais pas de possiblité pour sauver le contenue .

    Qlq'un peux m'aider a faire exporter - sauver - le contenue SVP ?


    Merçi
    Bonsoir à toutes et à tous,
    Pour extraire le contenu d'un fichier "CHM" dans un dossier, je te propose ce code,qui est en faite une application console.elle ne prend pas en charge les fichier "HELP".
    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
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    program decompiler_fichier_chm;
     
    {$APPTYPE CONSOLE}
     
    uses
      Windows,
      Classes,
      ActiveX,
      AxCtrls,
      ComObj,
      SysUtils;
     
    const
      CLSID_ITStorage: TGUID = (D1: $5D02926A; D2: $212E; D3: $11D0;
        D4: ($9D, $F9, $00, $A0, $C9, $22, $E6, $EC));
      IID_ITStorage: TGUID = (D1: $88CC31DE; D2: $27AB; D3: $11D0;
        D4: ($9D, $F9, $00, $A0, $C9, $22, $E6, $EC));
     
    var
      SaveFolderPathLength: Integer;
     
    type
      TCompactionLev = (COMPACT_DATA, COMPACT_DATA_AND_PATH);
     
      PItsControlData = ^TItsControlData;
      _ITS_Control_Data = record
        cdwControlData: UINT;
        adwControlData: array [0..0] of UINT;
      end;
      TItsControlData=_ITS_Control_Data;
     
      IItsStorage = interface(IUnknown)
        ['{88CC31DE-27AB-11D0-9DF9-00A0C922E6EC}']
        function StgCreateDocFile(const pwcsName: PWideChar; grfMode: DWORD;
          reserved: DWORD; var ppstgOpen: IStorage): HRESULT; stdcall;
        function StgCreateDocFileOnILockBytes(plkbyt: ILockBytes; grfMode: DWORD;
          reserved: DWORD; var ppstgOpen: IStorage): HRESULT; stdcall;
        function StgIsStorageFile(const pwcsName:  PWideChar): HRESULT; stdcall;
        function StgIsStorageILockBytes(plkbyt: ILockBytes): HRESULT; stdcall;
        function StgOpenStorage(const pwcsName: PWideChar; pstgPriority: IStorage;
          grfMode: DWORD; snbExclude: TSNB; reserved: DWORD;
          var ppstgOpen: IStorage): HRESULT; stdcall;
        function StgOpenStorageOnILockBytes(plkbyt: ILockBytes;
          pStgPriority: IStorage; grfMode: DWORD; snbExclude: TSNB;
          reserved: DWORD; var ppstgOpen: IStorage): HRESULT; stdcall;
        function StgSetTimes(const lpszName: PWideChar;
          const pctime, patime, pmtime: TFileTime): HRESULT; stdcall;
        function SetControlData(pControlData: PItsControlData): HRESULT; stdcall;
        function DefaultControlData(
          var ppControlData: PItsControlData): HRESULT; stdcall;
        function Compact(const pwcsName: PWideChar;
          iLev: TCompactionLev): HRESULT; stdcall;
      end;
     
      procedure ShowHelp;
      begin
        Writeln('Utiliser: decompiler_fichier_chm.exe [Chemin à Fichier CHM ]');
      end;
     
      procedure ExtractLog(IsStorage: Boolean; const Value: string);
      begin
        if IsStorage then
          Writeln('Dossier créé: ',
            Copy(Value, SaveFolderPathLength, Length(Value)))
        else
          Writeln('Extraction du Stream : ',
            Copy(Value, SaveFolderPathLength, Length(Value)))
      end;
     
      function WaitKeyboardInput(const Promt: string): Char;
      var
        Done: Boolean;
        IR: INPUT_RECORD;
        hCon: THandle;
        NumOfEvents,
        NumOfEventsRead: DWORD;
        I: Integer;
      begin
        Writeln;
        Writeln(Promt);
        Result := #0;
        Done := False;
        hCon := GetStdHandle(STD_INPUT_HANDLE);
        try
          while not Done do
          begin
             if not GetNumberOfConsoleInputEvents(hCon, NumOfEvents) then
               raise EInOutError.CreateFmt(
                'GetNumberOfConsoleInputEvents manqué %s',
                [SysErrorMessage(GetLastError)]);
             if NumOfEvents <= 0 then Continue;
             for I := 0 to NumOfEvents - 1 do
             begin
               if (not ReadConsoleInput(hCon, ir, 1, NumOfEventsRead)) then
                 raise EInOutError.CreateFmt(
                  'ReadConsoleInput manqué %s', [SysErrorMessage(GetLastError)]);
               Done :=
                (NumOfEventsRead = 1) and
                (IR.EventType = KEY_EVENT) and
                TKeyEventRecord(IR.Event).bKeyDown;
               if Done then
                 Result := TKeyEventRecord(IR.Event).AsciiChar;
             end;
          end;
        except
          on E : Exception do
           Writeln(Format('Exception: %s', [E.Message]));
        end;
      end;
     
      procedure ClearScreen;
      var
        ActualCoord, ZeroCoord: TCoord;
        cWritten: DWORD;
        hStdout: THandle;
        chFillChar: Char;
      begin
        hStdout := GetStdHandle(STD_OUTPUT_HANDLE);
        ActualCoord := GetLargestConsoleWindowSize(hStdout);
        ZeroMemory(@ZeroCoord, SizeOf(TCoord));
        chFillChar := ' ';
        FillConsoleOutputCharacter(hStdout, chFillChar,
          ActualCoord.X * ActualCoord.Y, ZeroCoord, cWritten);
        SetConsoleCursorPosition(hStdout, ZeroCoord);
      end;
     
      function ValidStorage(const Path: string): Boolean;
      var
        ITS: IItsStorage;
      begin
        Result := False;
        OleCheck(CoCreateInstance(CLSID_ITStorage, nil,
          CLSCTX_INPROC_SERVER, IID_ITStorage, ITS));
        if FileExists(Path) then
          Result := ITS.StgIsStorageFile(StringToOleStr(Path)) = S_OK;
      end;
     
      procedure ExtractStream(const RootPath: string; Root: IStorage;
        const StreamName: string);
      var
        TmpStream: IStream;
        OS: TOleStream;
        FS: TFileStream;
        FilePath: string;
      begin
        OleCheck(Root.OpenStream(StringToOleStr(StreamName),
          nil, STGM_READ or STGM_SHARE_EXCLUSIVE, 0, TmpStream));
        OS := TOleStream.Create(TmpStream);
        try
          FilePath := IncludeTrailingPathDelimiter(RootPath) + StreamName;
          FS := TFileStream.Create(FilePath, fmCreate);
          try
            OS.Position := 0;
            FS.CopyFrom(OS, OS.Size);
            ExtractLog(False, FilePath);
          finally
            FS.Free;
          end;
        finally
          OS.Free;
        end;
      end;
     
      procedure ExtractFolder(const RootPath: string; Root: IStorage);
      var
        ShellMalloc: IMalloc;
        Enum: IEnumStatStg;
        Fetched: Int64;
        TmpElement: TStatStg;
        ChildFolder: IStorage;
        ChildPath: string;
      begin
        if (CoGetMalloc(1, ShellMalloc) <> S_OK) or (ShellMalloc = nil) then
          raise EComponentError.Create('CoGetMalloc manqué.');
        OleCheck(Root.EnumElements(0, nil, 0, Enum));
        Fetched := 1;
        while Fetched > 0 do
          if Enum.Next(1, TmpElement, @Fetched) = S_OK then
            if ShellMalloc.DidAlloc(TmpElement.pwcsName) = 1 then
            try
              if TmpElement.dwType = STGTY_STORAGE then
              begin
                OleCheck(Root.OpenStorage(TmpElement.pwcsName, nil,
                  STGM_READ or STGM_SHARE_EXCLUSIVE, nil, 0, ChildFolder));
                ChildPath := IncludeTrailingPathDelimiter(RootPath) +
                  string(TmpElement.pwcsName);
                ForceDirectories(ChildPath);
                ExtractLog(True, ChildPath);
                ExtractFolder(ChildPath, ChildFolder);
              end
              else
              begin
                ExtractStream(RootPath, Root, string(TmpElement.pwcsName));
              end;
            finally
              ShellMalloc.Free(TmpElement.pwcsName);
            end;
      end;
     
      procedure Decompile(const Path: string);
      var
        ITS: IItsStorage;
        Root: IStorage;
        SaveFolderPath: string;
      begin
        OleCheck(CoCreateInstance(CLSID_ITStorage, nil,
          CLSCTX_INPROC_SERVER, IID_ITStorage, ITS));
        OleCheck(ITS.StgOpenStorage(StringToOleStr(Path), nil,
          STGM_READ or STGM_SHARE_EXCLUSIVE, nil, 0, Root));
        SaveFolderPath := ExtractFileName(Path);
        SaveFolderPath := Copy(SaveFolderPath, 1, Length(SaveFolderPath) -
          Length(ExtractFileExt(Path)));
        SaveFolderPath := ExtractFilePath(Path) +
          UpperCase(SaveFolderPath) + '_DUMP';
        ForceDirectories(SaveFolderPath);
        Writeln('Dossier créé du dump: ', SaveFolderPath);
        SaveFolderPathLength := Length(SaveFolderPath) + 1;
        ExtractFolder(SaveFolderPath, Root);
        Writeln;
        Writeln('Toutes les taches ont été executéés');
      end;
     
    begin
      try
        ClearScreen;
        CoInitialize(nil);
        if ParamCount = 0 then
          ShowHelp
        else
        begin
          if ValidStorage(ParamStr(1)) then
            Decompile(ParamStr(1))
          else
            Writeln(ExtractFileName(ParamStr(1)), ' Format du fichier incorrect.');
        end;
      except
        on E: Exception do
          Writeln(E.Message);
      end;   
      WaitKeyboardInput('Appuyez sur n''importe quelle touche pour continuer...')
    end.
    ça marche nickel.

    Peut-être ça intéressera d'autres développeurs.

    Voici ton fichier CHM dumpé avec cette application.

    A+

    NABIL74
    Fichiers attachés Fichiers attachés

Discussions similaires

  1. [Bureautique] Générateur de fichier hlp, chm
    Par ben_popcorn dans le forum Autres Logiciels
    Réponses: 4
    Dernier message: 03/02/2009, 20h57
  2. Création d'une aide (chm, hlp, etc.)
    Par Invité dans le forum Windows
    Réponses: 2
    Dernier message: 12/12/2007, 22h46
  3. [XSLT]Fichier d'aide CHM/HLP sur XTL/XSTL ?
    Par domiq44 dans le forum XSL/XSLT/XPATH
    Réponses: 4
    Dernier message: 31/10/2007, 13h23
  4. Réponses: 2
    Dernier message: 01/02/2007, 09h06
  5. Fichier d'aide : hlp ou chm ? (D7)
    Par arnaudG dans le forum Outils
    Réponses: 3
    Dernier message: 21/04/2006, 18h13

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