Solved

extract files

Posted on 2000-04-07
7
370 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

832 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