License:
BSD style: see license.txtAuthors:
Tomasz Stachowiak, Anders BerghExample:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | void main() { if (auto lib = SharedLib.load(`c:\windows\system32\opengl32.dll`)) { Trace.formatln("Library successfully loaded"); void* ptr = lib.getSymbol("glClear"); if (ptr) { Trace.formatln("Symbol glClear found. Address = 0x{:x}", ptr); } else { Trace.formatln("Symbol glClear not found"); } lib.unload(); } else { Trace.formatln("Could not load the library"); } assert (0 == SharedLib.numLoadedLibs); } |
Note:
SharedLib is thread-safe.Note:
Please use this function instead of the constructor, which is private.Params:
path | The path to a shared library to be loaded |
mode | Library loading mode. See LoadMode |
Returns:
A SharedLib instance being a handle to the library, or throws SharedLibException if it could not be loadedNote:
Please use this function instead of the constructor, which is private.Params:
path | The path to a shared library to be loaded |
mode | Library loading mode. See LoadMode |
Returns:
A SharedLib instance being a handle to the library, or null if it could not be loadedNote:
It's invalid to use the object after unload() has been called, as unload() will delete it if it's not referenced any more. Throws SharedLibException on failure. In this case, the SharedLib object is not deleted.Note:
It's invalid to use the object after unload() has been called, as unload() will delete it if it's not referenced any more.Params:
name | The name of the symbol; must be a null-terminated C string |
Returns:
A pointer to the symbol or throws SharedLibException if it's not present in the library.Params:
name | The name of the symbol; must be a null-terminated C string |
Returns:
A pointer to the symbol or null if it's not present in the library.