how to use dll

Sergey Gromov snake.scaly at gmail.com
Sun Jan 25 16:10:14 PST 2009


Wed, 21 Jan 2009 23:19:48 -0500, reimi gibbons wrote:

> I'm currently developing a software with D and Tango. I don't have
> much knowledge on DLL, but i do know when linking to static lib you
> need a .h header file, but do i need .h for linking with DLL as well?
> 
> 
> also can anybody please provide a quick and small example to link
> with DLL. 

The easiest way is to link with an import library.  It's exactly like
linking with a static library.  Actually you *are* linking with a static
library, but that's a special kind of static library which forwards your
calls to a DLL.  This way runtime automatically loads the DLL before
your program starts and unloads it after main() terminates, so you don't
need to bother yourself with details.

As Daniel pointed out, you can try to convert an existing .h file into a
.d file using htod:

http://www.digitalmars.com/d/2.0/htod.html

The most reliable way to get an import library for your DLL is to get a
.lib file in COFF format provided with the DLL and convert it into OMF
format using coffimplib:

ftp://ftp.digitalmars.com/coffimplib.zip


More information about the Digitalmars-d-learn mailing list