When to Use Packages and DLLs
Go Up to Creating Packages and DLLs
For most applications, packages provide greater flexibility and are easier to create than DLLs. However, there are several situations where DLLs would be better suited to your projects than packages:
- Your code module will be called from non-Delphi applications.
- You are extending the functionality of a Web server.
- You are creating a code module to be used by third-party developers.
- Your project is an OLE container.
You cannot pass Delphi run-time type information (RTTI) across DLLs to or from a DLL to an executable. If you pass an object from one DLL to another DLL or an executable, you will not be able to use the is or as operators with the passed object. This is because the is and as operators need to compare RTTI. If you need to pass objects from a library, use packages instead, as these can share RTTI. Similarly, you should use packages instead of DLLs in Web Services because they are on Delphi RTTI.
You cannot pass run-time type information (RTTI) across DLLs or from a DLL to an executable. That's because DLLs all maintain their own symbol information. If you need to pass a TStrings object from a DLL then using an is or as operator, you need to create a package rather than a DLL. Packages share symbol information.