Calling a DLL

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Apr 25 19:15:33 PDT 2011


You'll need a couple of things:

Link with the user32.dll import library, which is located in
DMD\dmd2\windows\lib\user32.lib.
Either pass it to DMD during compilation or more simply just can add a
pragma(lib) in your source file like so:
pragma(lib, "user32.lib");

And you need the function prototype. for windows api it needs the
extern(Windows) calling convention. So your code would look like:
http://codepad.org/hvOPpP9c

You are better off using the WindowsAPI bindings project, which
includes almost all windows api function prototypes. You can download
and read about it here:
http://dsource.org/projects/bindings/wiki/WindowsApi


More information about the Digitalmars-d-learn mailing list