• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 405
  • Last Modified:

How can i store exe file in my delphi Program

How can i store exe file in my delphi Program?
0
rmloh
Asked:
rmloh
  • 8
  • 8
  • 3
  • +1
1 Solution
 
viktornetCommented:
Here is an article from UNDU...
=========================
Put Anything In Your Delphi EXE!

by William A. Portillo - hallcom@wantree.com.au

I don't know if this is useful stuff but after a couple of weeks of playing with the
resources side of Delphi, I ended up writing a routine that will &quotextract" other
files out of a Delphi EXE. I found this useful for distributing little picture or sound files
with the application or as a setup program with internal files. No doubt many of you
will find other uses for this technique.

First, I create an RC project with NOTEPAD.EXE and ARJ.EXE in it as follows (we'll
call it RESJUNK.RC):

 NOTEPAD EXEFILE C:\WINDOWS\NOTEPAD.EXE
 ARJ EXEFILE C:\UTILS\ARJ.EXE

then I compile it with BRCC32 into a RES file. After this I include it in my Delphi
project by using the $R compiler directive like this:

{$R RESJUNK.RES}

and extract this files by using the TResourceStream class.

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

I hope this proves to be relevant to someone at least. If you want to share ideas on
this, please email me. If you mail me back, please put &quotWP:" on the subject line.
This lets my boss know that the mail is for me.
=========================
Hope this helps...

Happy New Year!

-Viktor
--Ivanov
0
 
rmlohAuthor Commented:
I DONT KNOW WOT TO WRITE HERE

TResourceStream.Create(Hinstance,*** Resname ***, Pchar(ResType));



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

0
 
viktornetCommented:
In our example where we declare this in our resource file
NOTEPAD EXEFILE C:\WINDOWS\NOTEPAD.EXE
ARJ EXEFILE C:\UTILS\ARJ.EXE
you should include NOTEPAD or ARJ in the place where it says RESNAME...e.g.

ExtractRes(RC_DATA, 'ARJ', 'Whatever');

-Viktor
--Ivanov

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
rmlohAuthor Commented:
There are message "ARJ not found".
0
 
slautinCommented:
I recommend to use BLOBs with LZARC-components. I did it not once (not only EXE, but PAS, DCU, BMP, XLS, DOC ant others).

0
 
viktornetCommented:
What the (Edited by Computer101) is that?

slautin, that's not (Edited by Computer101)ing true.. The best and easiest way is as I mentioned.

rmloh, Are you a newbie or what?? That's just an example. I know you don''t have ARJ, that was just an eaxmle.. YOu should substitute it with the EXE file that you want and the path to the file....  Man and oyu have been rejecting my answers just because you do the mistakes. My answer is completly correct. I'd really like to receive the credit for which I helped you with. I hate when I help someone and someone else like slautin gets in and answers without thinking if it's the easiest and best answer....

-Viktor
--Ivanov
0
 
intheCommented:
"ARG NOT FOUND" LoL ,
 rmloh have you read viktor's answer and comments ??
This is easiest way to do it for any type of file including exe
obviously if you dont have arg you replace it with a file you do have like as viktor said notepad .if you are new at this try reading the sources more and if you dont understand try looking at the delphi help or asking what specific functions mean.
 
 my 2 cents
Regards Barry
 
 

0
 
rmlohAuthor Commented:
slautin wher can i find the components??
0
 
viktornetCommented:
rmloh, don't you understand?? Those components are for compressing data and that's not of your use. The way to do it is as I told you. That's the easiest way to use and the one that you don't have to do lots of coding...

-Viktor
--Ivanov
0
 
rmlohAuthor Commented:
OK viktornet but i did wot you tolld my to do
and it is"t work can you pleas send my yors fles
for a EXE to ian@gezernet.co.il
0
 
viktornetCommented:
Ok, I'll make you an example...
0
 
rmlohAuthor Commented:
ok
0
 
viktornetCommented:
rmloh, I sent you a demo... YOu just need to compile it and press the button. Notepad would be extracted and saved to your desktop. The resource file is ResFile.rc which is actually a text file and you can see its contents. Then I compiled it with brcc32.exe and it gave me the ResFile.res... I included resfile.res in delphi by doing the following...

{$R RESFILE.RED}

Then I use the code I showed you above and it worked....

I hope now you can reject that person's answer and let me answer it and get the credit I deserve... 10q

-Viktor
--Ivanov
0
 
rmlohAuthor Commented:
I go the Email and it works but
you tolld my to write in *.rc
NOTEPAD EXEFILE C:\WINDOWS\NOTEPAD.EXE
and you write
NOTEPAD RCDATA C:\windows\notepad.exe
now how to you wont to get yours Points
0
 
rmlohAuthor Commented:
answer viktornet
0
 
viktornetCommented:
Ok, Here is my answer :)

btw- I told you to write EXEFILE because I just copied the article and pasted it.... When I try to make a demo project, it didn't work out so I had to change it to RCDATA... That's all... Happy Coding....

-Viktor
--Ivanov
0
 
slautinCommented:
Specially for VICTORNET!!!
What is '(Edited by Computer101)'? I didn't understand.
Are you want to write "flame out" or %#$%#$%#$%#$?
My be you know what's "(Edited by Computer101)ing true"? It's new language?
Type me, I know only "false" or "true" in coding.
In different conferences you'll get "(Edited by Computer101)" yourself.

Are you a professional or not?
Then talk as professionals, but not as ^$%^66456456$%^...

With best regards,
Slautin.
0
 
slautinCommented:
rmloh
are you need lz-component?
0
 
viktornetCommented:
slautin.... Keep ur professional mouth shut, 'cuz I'm sick of u aready... and u've been here for only 2 days... As a matter of fact I don't need no &%&^$@#&^!@%#*^$#!@$ script to express my self...
0
 
rmlohAuthor Commented:
Good by viktornet :-)
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.

  • 8
  • 8
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now