2

I have to maintain an Delphi 7 application. I've received the source code of this app, and when I try to open .DFM file or .DCU file by Notepad++, some of them display normaly with the source code, but some of them display incorrect with strange characters. How can I recover these file I will appreciate your help

OnTheFly
  • 2,059
  • 5
  • 26
  • 61
user2411800
  • 47
  • 1
  • 7
  • *"I have to maintain an Delphi 7 application", "I don't install Delphi 7 because it's not free", "I installed Delphi 7"* You are not making a lot of sense here. – David Heffernan May 23 '13 at 07:57

1 Answers1

3

For the .DFM, you can either:

  • Open the file in the IDE, right-click the form, and check Text DFM and then save it, or
  • From a command prompt in the folder where the .dfm is located, run convert <dfmfile.dfm>, which will convert it to text format with the same name. (Convert.exe is located in your $(DELPHI)\Bin folder, where $(DELPHI) refers to the root folder of your Delphi 7 installation).

The .dcu is compiled (binary) code, so to view it you need to open the .pas file with the same name (eg., if you have Unit1.dcu, you view it's source by opening Unit1.pas). There's no way to view the .dcu as text, because it isn't text.

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • Thanks for your help, but now I don't install Delphi 7 because it's not free:( Is there another way to open DFM file without Delphi 7 (with Notepad++ or Lazarus)? – user2411800 May 23 '13 at 02:59
  • 1
    If you have to maintain a Delphi 7 application, you need Delphi. You can't edit a binary .DFM file with Notepad++. I don't know if Lazarus includes a utility similar to convert, but that isn't the question you asked here. (You didn't mention Lazarus at all, as a matter of fact.) I also don't know if one of the Delphi trial versions will work for converting the .DFM files, because I've never tried them. Expect to run into major problems without having Delphi if the project contains third party components as well; many of them don't work in Lazarus/FPC. – Ken White May 23 '13 at 03:02
  • Thanks for your help, I installed Delphi 7 and open .DFM file properly. – user2411800 May 23 '13 at 04:08