Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to manipulate .res files?

Status
Not open for further replies.

Nordlund

Programmer
Jul 17, 2001
458
SE
Hi.
Does anyone know how to manipulate .res files from Delphi.



//Nordlund
 
Use the Image Editor. At least thats how BCB deals with it. I guess Delphi isn't any different.
 
Hi.
I want to edit .res files with Delphi by code in runtime, not using 3rd party applications...

Thanks anyway, hansaplast...

//Nordlund
 
Hi,

Have a look at You'l find as a discriptor for RES that it's a compiled (binary) file. It is usually created by a resourcecompiler, Borland called it brcc32 in Delphi's bin directory, by compiling the info in a RC file. This RC is a script-like parameter file where one can define resources to be linked into the final EXE using any modern linker.
So usually a RES file is not deployed with any software, except when it has to be used to generate some kind of EXE or DLL files.

If you need to generate a RES file from your app, write a RC and call "BRCC32 <resourcescript.rc>" and the RES file wil be there a few seconds later ;-)

HTH
TonHu
 
Hi Guys,

I am using Delphi 7 Enterprise, and I cannot find BRCC32 in my bin directory. Are things done a different way in Delphi 7? I've been using the Image Editor to edit .res files, but now I want to add a JPEG resource, and want to make my own .rc to compile into a .res. Can I obtain this program from another source?

-Tony
 
Hi nordlund,

there is a resource explorer demo that gives great insight
about resources. you can find the demo in <your delphi dir>\Demos\ResXplor. if things are not clear please let me know...

HTH,
Daddy

--------------------------------------
What You See Is What You Get
 
Ajbufort:
Just checked my D7 bin dir and its there Ok, so maybe your setup isn't good?

Nordlund:
I wrote an answer before on this issue: thread102-637294

HTH
TonHu
 
how to Include a JPEG in your EXE file

Create a resource script file MyPic.RC with Notepad and add the following line: 1 RCDATA "Pic.jpg"

Then use Borland's Resource Compiler BRCC32.EXE (a commandline tool) to compile it into a .RES file:
BRCC32 MyPic.RC

Add a compiler directive to the source code of your program.
It should immediately follow the form directive, as shown here:
{$R *.DFM}
{$R MyPic.RES}

Use the following code in your application:

procedure LoadJPEGfromEXE;
var
MyJPG : TJPEGImage; // JPEG object
ResStream : TResourceStream; // Resource Stream object
begin
try
MyJPG := TJPEGImage.Create;
ResStream := TResourceStream.CreateFromID(HInstance, 1, RT_RCDATA);
MyJPG.LoadFromStream(ResStream); // What!? Yes, that easy!
Canvas.Draw(12,12,MyJPG); // draw it to see if it really worked!
finally
MyJPG.Free;
ResStream.Free;
end;
end; // procedure

Aaron Taylor
John Mutch Electronics
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top