Browse Source

Added cross platform compatibility for LoadLibrary function.

git-svn-id: https://emgucv.svn.sourceforge.net/svnroot/emgucv/trunk@1511 d7f09016-e345-0410-b530-edf29a71df78
UWP10
canming 14 years ago
parent
commit
fd3cb43889
  1. 25
      Emgu.Util/Toolbox.cs

25
Emgu.Util/Toolbox.cs

@ -429,9 +429,28 @@ namespace Emgu.Util
/// Maps the specified executable module into the address space of the calling process.
/// </summary>
/// <param name="dllname">The name of the dll</param>
/// <returns>The handle to the library</returns>
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(String dllname);
/// <returns>The handle to the library</returns>
public static IntPtr LoadLibrary(String dllname)
{
if (Platform.OperationSystem == TypeEnum.OS.Windows)
{
return WinAPILoadLibrary(dllname);
}
else
{
return Dlopen(dllname, 0);
}
}
[DllImport("kernel32.dll", EntryPoint="LoadLibrary")]
private static extern IntPtr WinAPILoadLibrary(
[MarshalAs(UnmanagedType.LPStr)]
String dllname);
[DllImport("libdl.so", EntryPoint = "dlopen")]
private static extern IntPtr Dlopen(
[MarshalAs(UnmanagedType.LPStr)]
String dllname, int mode);
/// <summary>
/// Decrements the reference count of the loaded dynamic-link library (DLL). When the reference count reaches zero, the module is unmapped from the address space of the calling process and the handle is no longer valid

Loading…
Cancel
Save