Solved

How can i store exe file in my delphi Program

Posted on 1998-12-26
20
396 Views
Last Modified: 2010-04-04
How can i store exe file in my delphi Program?
0
Comment
Question by:rmloh
[X]
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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

717 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