AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Chm dump

Ein Thema von mohfa · begonnen am 5. Mai 2009 · letzter Beitrag vom 8. Mai 2009
Antwort Antwort
Seite 1 von 2  1 2      
mohfa

Registriert seit: 11. Feb 2007
97 Beiträge
 
Delphi 7 Enterprise
 
#1

Chm dump

  Alt 5. Mai 2009, 12:41
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
Angehängte Dateien
Dateityp: rar chmdump_919.rar (20 Bytes, 13x aufgerufen)
  Mit Zitat antworten Zitat
mohfa

Registriert seit: 11. Feb 2007
97 Beiträge
 
Delphi 7 Enterprise
 
#2

Re: Chm dump

  Alt 5. Mai 2009, 22:10
i'm very sorry , the attachment was empty .

please see the new attachment.


sorry again .
Angehängte Dateien
Dateityp: rar chmdump_232.rar (29,6 KB, 13x aufgerufen)
  Mit Zitat antworten Zitat
nahpets
(Gast)

n/a Beiträge
 
#3

Re: Chm dump

  Alt 6. Mai 2009, 09:33
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;
  Mit Zitat antworten Zitat
mohfa

Registriert seit: 11. Feb 2007
97 Beiträge
 
Delphi 7 Enterprise
 
#4

Re: Chm dump

  Alt 6. Mai 2009, 12:46
many thanks nahpets , Is there any possibility to Save the IStorage Contents without using the Treeview at all .

thank you again
  Mit Zitat antworten Zitat
mohfa

Registriert seit: 11. Feb 2007
97 Beiträge
 
Delphi 7 Enterprise
 
#5

Re: Chm dump

  Alt 6. Mai 2009, 23:18
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
  Mit Zitat antworten Zitat
nahpets
(Gast)

n/a Beiträge
 
#6

Re: Chm dump

  Alt 7. Mai 2009, 10:42
Hello,

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

[Edit]new version with errorlogging[/Edit]

Geändert von nahpets (21. Nov 2017 um 16:41 Uhr)
  Mit Zitat antworten Zitat
mohfa

Registriert seit: 11. Feb 2007
97 Beiträge
 
Delphi 7 Enterprise
 
#7

Re: Chm dump

  Alt 7. Mai 2009, 19:43
How can i thank you nahpets .


Many thanks
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.540 Beiträge
 
Delphi 11 Alexandria
 
#8

Re: Chm dump

  Alt 7. Mai 2009, 19:44
Just buy him a beer . If he does not want it, I will take it
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
mohfa

Registriert seit: 11. Feb 2007
97 Beiträge
 
Delphi 7 Enterprise
 
#9

Re: Chm dump

  Alt 7. Mai 2009, 21:06
10 beers not only ONE
  Mit Zitat antworten Zitat
nahpets
(Gast)

n/a Beiträge
 
#10

Re: Chm dump

  Alt 8. Mai 2009, 08:02
okay, 10 beers for DeddyH
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:46 Uhr.
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