1

I have no experience with dlls right now. My application consists of several programs with several Forms and units. Now I want to put them all "together". That means, I want to have one Login that would call these separate programs from dlls.

Since the programs have several units themselves, my question is, whether it is possible to put more than one Form / Unit into one DLL. (a complete program) Then I could call the Programs as dlls.

Until now the programs run separately, there are no dependencies between them. Inside them there are cascading forms (Form1 calls Form2 or form3 or ...). If it is not possible to put them all together in one dll, can I cascade dlls (i.e. call dll 1 dll1 calls dll 2)?

I use Delphi 2007 / XE with Firebird 2.x via IBDac

TIA

Rolf L
  • 21
  • 4
  • 1
    Consider using `bpl` packages instead of dlls. You can also create design time packages with your components and install them into your IDE. Read more about bpls here: http://edn.embarcadero.com/article/27178 – Adam Jul 22 '12 at 15:57
  • As far as I know bpl and dll are (inside the delphi world) somehow interchangeable in that sense, that, after making the decision which of them to use, I can do the same with them? (except call functions from other Languages) – Rolf L Jul 23 '12 at 08:31
  • You don't need DLLs. Just include all the code into a single program. – David Heffernan Jul 23 '12 at 09:06
  • well, TObject in DLL and in EXE would be two different classes. All "as" and "is" operators would be non-working. No type safety. Make function Somefunction(parameter: string): TObject; and call it var-string := SomeFunction (2+2, 3.5 + 3.5, Tform). Easily. With any random result. If you do not know assembler well enough to understand the difference between DLLs and BPL - then don;t use DLL. – Arioch 'The Jul 23 '12 at 14:40

3 Answers3

2

Be aware that instance of Application object in DLL and in EXE will be separate. You have to pass Application.Handle to your DLL from Exe and set it. Otherwise you'll get the separate application button on Windows taskbar.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Alexander Shagin
  • 485
  • 5
  • 13
1

Yes, you can put as many units as you want in a DLL. Those units can have forms associated with them or not, just like in any other Delphi project.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
  • So the DLL is like any other project ? Starting out from a dll I could create a whole application in a dll? Except that I would need a starting App? – Rolf L Jul 23 '12 at 08:28
  • Yes, User, exactly. You could export a function, and then the host application could call it. (That's what the Python programming language does, for example.) For your purposes, a BPL would probably be more suitable since it makes it easier to share Delphi-specific features between the host program and the external module, but remember that the question you asked was about the capabilities of DLLs, not about the best way to accomplish your specific task. – Rob Kennedy Jul 23 '12 at 12:54
1

If there isn't any specific reason to use DLLs (such as being able to call them from / write them in other programming languages), you should consider using packages instead.

You can put as many units and forms into a package as you like but beware that the unit names must be unique: You cannot load multiple packages containing the same unit (but you can put these units into a separate package that is used by multiple packages).

dummzeuch
  • 10,975
  • 4
  • 51
  • 158