An interface definition to hide the platform specific aspects of library loading
IDynamicLibraryLoader
00 Remarks
There are probably projects 'out there' doing this already, but nothing is obvious from a quick search. Re-consider again if you need more features.
01 Syntax
Microsoft.VisualBasic.ApplicationServices.DynamicInterop.IDynamicLibraryLoader
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| LoadLibrary | 1 | Load a native library (DLL on windows, shared libraries on Linux and MacOS) |
| GetLastError | 1 | Gets the last error message from the native API used to load the library. |
| FreeLibrary | 1 | Unloads a library |
| GetFunctionAddress | 1 | Gets a pointer to the address of a native function in the specified loaded library |
03 Members
LoadLibrary(
String)Load a native library (DLL on windows, shared libraries on Linux and MacOS)
Parameters
| Name | Type | Description |
|---|---|---|
filename | String | The file name (short file name) of the library to load, e.g. R.dll on Windows |
GetLastError
Gets the last error message from the native API used to load the library.
FreeLibrary(
IntPtr)Unloads a library
Parameters
| Name | Type | Description |
|---|---|---|
handle | IntPtr | The pointer to the entry point of the library |
GetFunctionAddress(
IntPtr, String)Gets a pointer to the address of a native function in the specified loaded library
Remarks
GetProcAddress
Parameters
| Name | Type | Description |
|---|---|---|
hModule | IntPtr | Handle of the module(library) |
lpProcName | String | The name of the function sought |
Returns
Handle to the native function