EricAnderton: There are some caveats to working with Dll's in D, these are largely due to D's status as a beta technology (for now).
- Bug: stdin/stdout will be set to an invalid state when a win32 D-dll (built against dmd) is unloaded.
- The dll stub code provided in the comments is incomplete (see example below)
- As is mentioned in the original code, multithreading is not explicitly handled in DllMain. You'll have to roll your own hooks for this.
EricAnderton: The DllMain provided on the digitalmars site doesn't catch exceptions during startup, nor does it execute the module destructors on process-detach. This is in contrast to the WinMain example that at least performs the exception handling.
The example below is a how to handle those two cases correctly: