You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

30 lines
1.1 KiB

using System;
using System.IO;
using System.Runtime.InteropServices;
public static class SystemLibrary
{
#if UNITY_STANDALONE_WIN
[DllImport("kernel32", EntryPoint = "LoadLibrary", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern IntPtr LoadLibraryNative(string lpFileName);
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetDllDirectory(string lpPathName);
public static IntPtr LoadLibrary(string lpFileName)
{
string lpPathName = Path.GetDirectoryName(lpFileName);
lpFileName = Path.GetFileName(lpFileName);
SetDllDirectory(lpPathName.Replace('/', '\\'));
return LoadLibraryNative(lpFileName);
}
[DllImport("kernel32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool FreeLibrary(IntPtr hModule);
[DllImport("kernel32")]
public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName);
#endif
}