delphidlldllexportdllmain

MSVC DLL loading: are __declspec(dllexport) functions loaded directly without DllMain


I tried to write a DLL project in VS C++ with some exported functions like below:

extern "C"  __declspec(dllexport) int function_sendNumber(unsigned num);

I noticed VS project comes with file dllmain.cpp containing DllMain entry function. However, i commented the DllMain function and use Delphi exe application to call the exported functions like below function pointer:

function  function_sendNumber(n : Integer): Integer; cdecl;
external 'DLLproject.dll';

The Delphi application successfully called the DLL exported function. I thought this method is DLL Explicit linking. So I want to understand clearly, is it Explicit Loading or implicit. If so how exported functions are loaded without DllMain. I don't find any calls to LoadLibrary to load DLL.


Solution

  • There are a number of terms that are more or less connected: