-3

Is there any way I can view a DCU file as a form?

Fabrizio
  • 7,603
  • 6
  • 44
  • 104
Icarus
  • 19
  • 2
    A .dcu is not a form. Forms are contained in .dfm files. – Ken White Aug 21 '19 at 00:19
  • What good would it do you anyway? You'd be able to see the visual elements of the form, but none of the code that is triggered by anything that happens on that form. – Ken White Aug 21 '19 at 00:28
  • Unless you reverse engineer the DCU for the Form's unit, but all that will give you is the compiled machine code, not the original Pascal code – Remy Lebeau Aug 21 '19 at 04:16
  • @remy You can't reverse engineer the form properties because they aren't in the dcu file. – David Heffernan Aug 21 '19 at 06:59
  • 3
    @DavidHeffernan I know that. I was merely commenting on Ken's hypothetical point about IF you could see the Form, you couldn't see the code behind it – Remy Lebeau Aug 21 '19 at 07:35
  • Even if the form details were stored inside the DCU files, that would still defeat the purpose, because DCU files are not meant for you to open/modify. In fact, closed-source libraries distribute only DCU files and not the original PAS files on purpose, because they don't want you to see the contents. – Jerry Dodge Aug 21 '19 at 19:05
  • I could imagine a compiled (to .res) dfm being stored in the DCU for easier/quicker combination into the final res file. – Marco van de Voort Aug 22 '19 at 21:39

2 Answers2

5

The form is stored in the dfm file and linked to the executable as ressources. That data simply doesn't exist in the dcu file, so you can't view it.

On top of that the dcu file format is not documented, so even if the form were stored there, any viewer would have to rely on implementation internals to work.

dummzeuch
  • 10,975
  • 4
  • 51
  • 158
3

DCU extension is used for Delphi Compiled Units

These are binary files so you can't see their contents as source code or as a rendered forms.

SilverWarior
  • 7,372
  • 2
  • 16
  • 22
  • 3
    dfm files can be binary. That dcu files are binary is not relevant. What matters is that dcu files don't contain the dfm content. – David Heffernan Aug 21 '19 at 06:58
  • 1
    @DavidHeffernan Yes DFM files can be stored either in textual or binary format. But you can use special programs like [PE Explorer](http://www.heaventools.com/overview.htm) to videw their content no matter of which storing format was used. But there no such tool dor DCU files – SilverWarior Aug 21 '19 at 08:35