Thema: Delphi Chm dump

Einzelnen Beitrag anzeigen

mohfa

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

Re: Chm dump

  Alt 7. Mai 2009, 00: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