How to Set one Dll as Delay Loading Dll?

2 12 2008


Nobody like delays. All of us want everything to be on time. May the the most hated characteristic might be the delaying nature. Well, while everyone hates delays, there is one special guy who loves delays – the Windows loader. 😀

delayloadingdll

Well, as you know the purpose of the windows loader is to load the an application file disk to memory and start the execution. While loading an executable, loader have to make sure that all the dlls required by application are also loaded to memory. But assume you have 50 dlls. Eventhough those dlls have to do nothing in application startup, its loader’s duty to load it. And when the dll count goes on, loader have to work more and there by your application needs more time to start. Well, how to make the startup more faster in this situation?


You could mark your dlls as delay loading dlls. If you have enabled delay loading dll option for the dll, then loader loads the dll only when application make the first function call to that dll. Hence, during application startup, the loader’s “load” can be reduced and it will improve startup time. In other words, you can call it as “Load on demand”.

Well for enabling delay loading for a dll, you have to specify the linker option /DELAYLOAD:dllname to linker settings. For instance, see the screenshot for how to enable delay loading for mydll.dll.

delayloadingdll2


Interesting to know that loaders love delays. Isn’t it? lazy loaders 😉


Targeted Audience – Intermediate.

Advertisements