2010. május 26., szerda

DLLs: Import dynamic or static


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 is that it is easy - it does not require ugly code. The application will only start up if all DLLs are present and can be loaded. 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

The following Article shows you how to do it: Dynamic loading and binding of DLLs

Nincsenek megjegyzések:

Megjegyzés küldése