importing DLL
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Fri Mar 28 09:58:43 PDT 2008
BCS wrote:
> Neal Alexander wrote:
>> BCS wrote:
>>
>>> I have a DLL with no .h no .def and nothing but the DLL. What are my
>>> odds of linking it in with a D app?
>>>
>>>
>>
>> implib.exe
>
> Tried that. It gives me a .lib (that doesn't seem to work but I could be
> mistaken) but I still don't know what functions are defined. (maybe I
> should have added "no documentation")
If you don't know what functions it defines things get tricky.
IIRC you should be able to determine their names somehow, but most DLLs
use C-like mangling[1] so there's no sure way to know what parameters
they expect or what they return.
And even if it's a (non-D[2]) mangling with parameter and type info it's
not much better unless you feel like writing e.g. some extern "C" C++
bindings. (Though then at least you know that should work, provided you
can demangle them)
I do seem to remember "stdcall"[3]-mangled names include the number of
bytes of parameters they expect though, so if based on that and the
function name you can make an educated guess as to their parameters and
return type...
[1]: In other words: pretty much no parameter & return type information.
[2]: For D mangling, running it through Phobos' std.demangle should
produce enough info to declare the right functions.
[3]: "extern(Windows)"
More information about the Digitalmars-d-learn
mailing list