[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

extract files

Posted on 2000-04-07
7
Medium Priority
?
392 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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:Tom 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 40 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

865 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