Mega Code Archive

 
Categories / Delphi / Examples
 

Dlls import dynamic or static

Both techniques have their advantages. Static importing means you define functions like this: function f : integer; external 'mydll.dll'; The advantage of static imports are: It is easy - it does not require ugly code. The application will only start up if all DLLs are present and can be loaded (this could also be considered a negative) All functions across all modules are bound during startup time. Dynamic importing has its advantages as well. It basically gives you full control over the usage of the DLL. If your DLL is only needed rarely for a seldomly used function, you may not want to load it at startup of your application. Your application will start faster then. If the application will work without that DLL to a usable extent, you may allow the user to do so. If you have different DLLs for different environments, for example one for Windows NT, another one for Windows 95 etc, then you MUST bind dynamic - you determine the operating system and load the DLL that you want. dynamic binding allows you to release the DLL if you do not need it anymore