Load D shared library on windows x64

Tofu Ninja joeyemmons at yahoo.com
Sat Aug 18 21:16:35 UTC 2018


On Saturday, 18 August 2018 at 21:10:55 UTC, Tofu Ninja wrote:
> On Saturday, 18 August 2018 at 11:27:29 UTC, Mike Wey wrote:
>> On 18-08-18 02:31, Tofu Ninja wrote:
>>> On Friday, 17 August 2018 at 20:27:05 UTC, Tofu Ninja wrote:
>>>> Its this part that fails... always returns null
>>>>
>>>> HMODULE h = cast(HMODULE) Runtime.loadLibrary(dllName);
>>>> if (h is null) {
>>>>     writeln("error loading");
>>>>     return;
>>>> }
>>> 
>>> 
>>> I there any way to see why Runtime.loadLibrary is failing? It 
>>> just returns null on error which is not very helpful.
>>
>> You can probably use: core.sys.windows.winbase.GetLastError
>
> That was helpful, error is:
>
> ERROR_DLL_INIT_FAILED
>
> 1114 (0x45A)
>
> A dynamic link library (DLL) initialization routine failed.


Thank you this helped lead me to the real error.
The problem was here

writeln("DLL_PROCESS_ATTACH");
Runtime.initialize();

Cant use writeln before Runtime.initialize


More information about the Digitalmars-d-learn mailing list