Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How can i store exe file in my delphi Program

Posted on 1998-12-26
20
391 Views
Last Modified: 2010-04-04
How can i store exe file in my delphi Program?
0
Comment
Question by:rmloh
  • 8
  • 8
  • 3
  • +1
20 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1353129
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
 

Author Comment

by:rmloh
ID: 1353130
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1353131
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:rmloh
ID: 1353132
There are message "ARJ not found".
0
 
LVL 1

Expert Comment

by:slautin
ID: 1353133
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1353134
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
 
LVL 17

Expert Comment

by:inthe
ID: 1353135
"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
 

Author Comment

by:rmloh
ID: 1353136
slautin wher can i find the components??
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1353137
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
 

Author Comment

by:rmloh
ID: 1353138
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1353139
Ok, I'll make you an example...
0
 

Author Comment

by:rmloh
ID: 1353140
ok
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1353141
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
 

Author Comment

by:rmloh
ID: 1353142
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
 

Author Comment

by:rmloh
ID: 1353143
answer viktornet
0
 
LVL 10

Accepted Solution

by:
viktornet earned 50 total points
ID: 1353144
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
 
LVL 1

Expert Comment

by:slautin
ID: 1353145
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
 
LVL 1

Expert Comment

by:slautin
ID: 1353146
rmloh
are you need lz-component?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1353147
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
 

Author Comment

by:rmloh
ID: 1353148
Good by viktornet :-)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi prevent click fast 2 238
Firemonkey android show image from resource ? 1 46
CheckListBox usage 3 71
Not able to call Delphi XE10 dll function from Delphi 6.0 4 37
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…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

860 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