Solved

extract files

Posted on 2000-04-07
7
368 Views
Last Modified: 2010-04-04
how to extract files from program or how to copy files from program to directory?
0
Comment
Question by:Jurica2505
7 Comments
 
LVL 6

Expert Comment

by:edey
ID: 2694621
Do you mean reasources that you have compiled into your exe? If so you would want to checkout TReasourceStream

GL
mike
0
 
LVL 5

Expert Comment

by:Gwena
ID: 2694712
listening
0
 
LVL 5

Expert Comment

by:Gwena
ID: 2694715
listening
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:umulig
ID: 2695082
Take a look at this link
http://www.gnomehome.demon.nl/uddf/pages/resource.htm

Regards
Umulig
0
 
LVL 4

Expert Comment

by:Radler
ID: 2702151
Hi Jurica,

There is a our pending at
http://www1.experts-exchange.com/Computers/Programming/Windows/Delphi/Q_10322797.html

Your trouble has better easy solution if you have Delhi 4 or above

#
At the menu Project->Resources open the Project resources.
RightClick the mouse and add a new type "RT_RCDATA"
After this select the file to incorporate inside you application.
You can repeat this to other file, the default name is RT_RCDATA_1.

Put the follow code to extract the resource file


function TMainFrm.XtractRes( DestFile : string ) : boolean;
var
  ZipRes : TResourceStream;
begin
  Result:=False;
  try
    ZipRes:=TResourceStream.Create( System.MainInstance, 'RT_RCDATA_1',                   'RT_RCDATA');
      try
                  ZipRes.SaveToFile( DestFile );
                except
        on E : exception do begin
              DeleteFile( DestFile );
              MessageDlg( 'I get the error: '#13 + E.Message, mtError, [mbOK], 0);
      end;
      end;
      ZipRes.Free;
      except
                     Result:=False;
                     Exit;
      end;
       Result:=True;
end;

T++, Radler.
0
 
LVL 5

Expert Comment

by:knowlton
ID: 2731089
If you are looking at integrating a Zip/Unzip functionality in to your Delphi app, try:

www.ziptv.com
0
 

Accepted Solution

by:
peteraa earned 20 total points
ID: 2918665
Heres a sample proggie I wrote that extracts Microsoft Compressed files from an exe

program testsfx;
uses
  Classes,
  Lzexpand,
  Windows, Sysutils;
  {$R *.res}
var
yesno: integer;
WinDir: PChar;

// You will need to create a resource script and compile it with the Borland Resource Compiler and then make sure it is included as a resource in your exe
//
// Note, these files must be compressed with the Microsoft Compress Utility...
// A resource script that included one file, C:\test.ex_ would be
// yourfile exefile C:\test.ex_


procedure ExtractRes(ResType, ResName, ResNewName : String);
var
   Res : TResourceStream;
   begin
     Res := TResourceStream.Create(Hinstance, Resname, Pchar(ResType));
     Res.SavetoFile(ResNewName);
     Res.Free;
end;

function CopyFile( src, dest: String): Boolean;
   var
      s, d: TOFStruct;
      fs, fd: Integer;
      fnSrc, fnDest: PChar;
   begin
      src:=src + #0;
      dest:=dest + #0;
      fnSrc:=@src[1];   { Trick the Strings into being ASCIIZ }
      fnDest:=@dest[1];

      fs := LZOpenFile( fnSrc, s, OF_READ );    { Get file handles }
      fd := LZOpenFile( fnDest, d, OF_CREATE );

      if LZCopy( fs, fd ) < 0 then      { Here's the magic API call }
         Result:=False
      else
         Result:=True;

      LZClose( fs );    { Make sure to close 'em! }
      LZClose( fd );
   end;


begin
yesno:=MessageBox(0, 'This program will extract whatever version ??'#13
     +#13
     +'Continue with install?','SFX by Peter Windridge - pjw62@lineone.net',MB_ICONQUESTION + MB_YESNO);
     if yesno = IDYES then
     begin
  {$I-}
  MkDir('C:\extractpath\');
 
  ExtractRes('ExeFile', 'yourfile', 'C:\extractpath\yourfile.ex_');

  if CopyFile('C:\exractpath\yourfile.ex_', 'C:\extractpath\yourfile.exe') then
  MessageBox(0, 'extraction and expansion successful!','SFX by Peter Windridge - pjw62@lineone.net',MB_ICONQUESTION + MB_OK);

  end;
  end.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now