I am having one xyz.pas file reference in my project. But that file is not with me. I am having the xyz.dcu and xyz.obj file of that xyz.pas file. When I tried to compile the project I have got the Error "xyz.dcu not found". So i have included the path of xyz.dcu in Search path. Now I am getting error "xyz.dfm not found".
Please suggest me the solution. Is it possible to compile the project with only .dcu and .obj files?
Thanks in advance. Regards, Naren
If you are still in the possesion of the executable, then you can extract your complete and original DFM file from the application resources by any arbitrary resource manager. For example: XN Resource Editor. In the RC DATA category, there will be an item called TXYZ.
I hope you haven't lost your work.
Simplified, Delphi works like this:
PAS+DFM => DCU
DCU+RES => EXE
More about Delphi files at the end of this answer.
You can compile the project if you only have the DCU file. First, remove the PAS file from your folder else Delphi will try to recompile it (and in order to recompile it, it needs the DFM file).
I don't think the Obj file will be of any use to you.
The DFM file is very very important for your project but yet not critical important. If you are in deep need, you can still go on without it as it can be reconstructed manually based on information you have in the PAS file and based on the way the application's GUI looks (if you have ever seen it running).
Here is the trick (involves some work):
Just create a new form and then look at the top of your original PAS file for the declaration of the form. It may look like this:
TYPE
TYourForm = class(TForm)
xLabel: TLabel;
yButton: TButton;
etc
etc
end;
Then put all those controls back to your new form and name them exactly as they are named in the PAS file (xLabel, yButton, etc). Arrange them to resemble the original GUI. When done, replace the new created PAS file with your original PAS file. IMPORTANT: the name of the DFM and PAS file should match. Compile and you are done! The rebuilt GUI may not look EXACTLY as the original one, but it should do it.
Hint:
There are tools that can extract the DFM file from DCU/EXE.
Here are some of them: www.delphi2.software.informer.com/download-delphi-extract-dfm
This will help you a lot!
.PAS - Delphi Source File
PAS should be stored in Source Control
In Delphi, PAS files are always the source code to either a unit or a form. Unit source files contain most of the code in an application. The unit contains the source code for any event handlers attached to the events of the form or the components it contains. We may edit .pas files using Delphi's code editor. Do not delete .pas files.
.DCU - Delphi Compiled Unit
A compiled unit (.pas) file. By default the compiled version of each unit is stored in a separate binary-format file with the same name as the unit file, but with the extension .DCU (Delphi compiled unit). For example unit1.dcu contains the code and data declared in the unit1.pas file. When you rebuild a project, individual units are not recompiled unless their source (.PAS) files have changed since the last compilation, or their .DCU files cannot be found. Safely delete .dcu file because Delphi recreates it when you compile the application.
.DFM - Delphi Form
DFM should be stored in Source Control
These files are always paired with .pas files. Dfm file contains the details (properties) of the objects contained in a form. It can be view as text by right clicking on the form and selecting view as text from the pop-up menu. Delphi copies information in .dfm files into the finished .exe code file. Caution should be used in altering this file as changes to it could prevent the IDE from being able to load the form. Form files can be saved in either binary or text format. The Environment Options dialog lets you indicate which format you want to use for newly created forms. Do not delete .dfm files.
source: delphi.about.com/od/beginners/a/aa032800a.htm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With