bind

Returns an instance of struct T with all fields pointing to corresponding symbols in dynamic library lib.

  1. void bind(DynamicLib lib, char[] symbolName)
  2. T bind(DynamicLib lib)
    @system
    T
    bind
    (
    T
    )
    (
    auto ref DynamicLib lib
    )
    if (
    is(T == struct)
    )

Throws

Exception if any corresponding symbol is not found or has null address.

Examples

version(Windows):

struct Kernel32
{
extern(Windows) nothrow:
	alias DWORD = uint;
	DWORD function() GetVersion, GetTickCount;
}
const kernel32 = DynamicLib("Kernel32.dll", true).bind!Kernel32();

import std.stdio;
writefln("GetVersion: %X", kernel32.GetVersion());
writefln("GetTickCount: %s", kernel32.GetTickCount());

Meta