7

I am going through my project code base, which consits of libraries and applications. Some libraries are Dll's. Code is written in C++ for Windows using MS VS 2010.

I taught for Dll we should write DllMain function which is entry point for the DLL application. But in my project for DLL "DllMain" function is not present.

My question when we require DllMain and when it is not required?

Thanks for your time and help.

venkysmarty
  • 11,099
  • 25
  • 101
  • 184

1 Answers1

16

DllMain is not mandatory. If you have some initialization code required to run when loading the dll, you should create a DllMain function, and treat the initialization there. Otherwise it's not required.

See here some more information.

Alexandru C.
  • 3,337
  • 1
  • 25
  • 27