That example was a bit incomplete, preceding was the following code:<div><br></div><div><div>import std.c.windows.windows;</div><div>import core.dll_helper;</div><div><br></div><div>pragma(lib,"kernel33.lib");</div>
<div><br></div><div>__gshared HINSTANCE g_hInst;</div><div><br></div><div>extern (Windows)</div><div>BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved)</div><div>{</div><div> switch (ulReason)</div><div>
{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>case DLL_PROCESS_ATTACH:</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> g_hInst = hInstance;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> dll_process_attach( hInstance, true );</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> break;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>case DLL_PROCESS_DETACH:</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> dll_process_detach( hInstance, true );</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> break;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>case DLL_THREAD_ATTACH:</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> dll_thread_attach( true, true );</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> break;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>case DLL_THREAD_DETACH:</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> dll_thread_detach( true, true );</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> break;</div><div> }</div><div> return true;</div><div>}</div><br><div class="gmail_quote"><br></div></div>