link from a dll to another function in another dll?

Robert Jacques sandford at jhu.edu
Sun Apr 17 17:55:05 PDT 2011


On Sun, 17 Apr 2011 16:09:02 -0400, maarten van damme  
<maartenvd1994 at gmail.com> wrote:

> Hello everyone, this is my second post in the digitalmars.d newsgroup  
> and I
> hope it gets as good support and suggestions as my first post :)
>
> I'm playing around with the d programming language and am trying out some
> exotic things you normally would write in c++.
> Right now I'm trying to 'intercept' all calls from a program to a dll by
> renaming that dll and writing my own in d.
> In c++ you would write in the header file:
> #pragma comment(linker,
> "/export:exportfunction=nameofotherdll.dll.destinationfunction, at location")
>
> How could one write this in the d programming language?
> Asuming this has to be done with the pragma(lib,...) function but I don't
> really know how.
>
> thanks in advance,
>
> Maarten

I don't know of an automated way of doing this is D. pragma(lib,...)  
exists, but it simply loads a specified static library. (i.e. to simplify  
linking/ project setup, etc). Personally, I'd just export  
extern(C)/extern(System) functions toa DLL, and link in a manually define  
the renamed DLL using a .def file and implib.


More information about the Digitalmars-d mailing list