Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Chm dump (https://www.delphipraxis.net/133590-chm-dump.html)

mohfa 5. Mai 2009 12:41


Chm dump
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hi , i've this project ( attachment )that deals with Chm ( Help Files ) , It populates the Contents into the Treeview .

But what i want is to export ( save ) the Contents into a Directory instead of populating them , any help please .


many thanks

mohfa 5. Mai 2009 22:10

Re: Chm dump
 
Liste der Anhänge anzeigen (Anzahl: 1)
i'm very sorry , the attachment was empty .

please see the new attachment.


sorry again .

nahpets 6. Mai 2009 09:33

Re: Chm dump
 
Hello,

do you mean something like this?

Delphi-Quellcode:
procedure TFrmMain.btnSaveToDirClick(Sender: TObject);
Var
          i   : Integer;
          sDir : String;
begin
  If OpenDialog.FileName = '' Then OpenDialog.FileName := EditHelpFile.Text;
  sDir := ChangeFileExt(OpenDialog.FileName,'');
  If Not DirectoryExists(sDir) then CreateDir(sDir);
  For i := 0 To Tree.Items.Count - 1 do begin
    Tree.Items[i].Selected := True;
    TreeChange(Sender,Tree.Items[i]);
    If Memo.Lines.Count > 0 then Memo.Lines.SaveToFile(sDir + '\' + Tree.Items[i].Text);
  end;
end;

mohfa 6. Mai 2009 12:46

Re: Chm dump
 
many thanks nahpets , Is there any possibility to Save the IStorage Contents without using the Treeview at all .

thank you again

mohfa 6. Mai 2009 23:18

Re: Chm dump
 
Hi i did it Now i can Export the IStorage elements to a Directory , but Why it doesn't export the SubStorage too ( Like Images , Jscripts .... ).

The Code to Export the IStorage Elemts is :

Delphi-Quellcode:
 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)) ;

   {* Here why it does't support the 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 :

Delphi-Quellcode:
procedure TFrmMain.Button1Click(Sender: TObject);
begin
ExportStgElemets(EditHelpFile.Text,'C:\test\');
end;
Could any one Correct the Code so that the Procedure can Export the SubStorage Too ??

Thank you

nahpets 7. Mai 2009 10:42

Re: Chm dump
 
Hello,

a new version with export of SubStorage ( Like Images , Jscripts .... ).

[Edit]new version with errorlogging[/Edit]

mohfa 7. Mai 2009 19:43

Re: Chm dump
 
How can i thank you nahpets . :roll:


Many thanks

DeddyH 7. Mai 2009 19:44

Re: Chm dump
 
Just buy him a beer :zwinker:. If he does not want it, I will take it :lol:

mohfa 7. Mai 2009 21:06

Re: Chm dump
 
10 beers not only ONE :lol:

nahpets 8. Mai 2009 08:02

Re: Chm dump
 
okay, 10 beers for DeddyH :wink:


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:59 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz