Adding an RC file directly to Delphi DPR

1.7k Views Asked by At

I'm working on taking control of some project options external to the IDE e.g. version numbering. I can do this OK if I either (i) compile the relevant RC file externally to create the RES file and include that in the DPR, or (ii) add the RC file to the project.

However, I cannot get it to work just by adding a line of the form {$R 'dummy.res' 'dummy.rc' } to the DPR. It will compile/build OK if and only if the RES file already exists. I'm using XE6 but I get the same behavior in XE and even Delphi 7.

But there are numerous answers that suggest that adding such a line to the DPR is all one needs to do. Can anyone clarify, please?

1

There are 1 best solutions below

10
On BEST ANSWER

I've been able to reproduce something similar to what you describe. It may or may not be the same problem as you.

I create a new project and put a .rc file alongside the top level project files. Then I add this line to the project file:

{$R myresource.res myresource.rc }

Then I compile and no .res file appears. Then I save the project and re-compile, and now the .res file appears.

After analysing this series of events, I think I understand what is going on. Until you save the project, there is nothing in the .dproj file to trigger the resource compile. When you save the project, this appears in the .dproj file:

<RcCompile Include="myresource.rc">
    <Form>myresource.res</Form>
</RcCompile>

It's quite plausible that this is what is happening to you.

I think that you are probably best either using the IDE to manage resources or to compile them yourself. The former is done, for instance, using the Resources and Images action on the Project menu. The latter can be done with pre-build actions.