Solved

extract files

Posted on 2000-04-07
7
364 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

12 Experts available now in Live!

Get 1:1 Help Now