Solved

How can i store exe file in my delphi Program

Posted on 1998-12-26
20
389 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

23 Experts available now in Live!

Get 1:1 Help Now