Make dndxc dll search path more user friendly (#904)

This commit is contained in:
Marcelo Lopez Ruiz 2017-12-11 09:18:06 -08:00 коммит произвёл GitHub
Родитель 08990d21e3
Коммит 546b159729
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -361,12 +361,19 @@ namespace DotNetDxc
[DllImport("kernel32.dll", CallingConvention = CallingConvention.Winapi, SetLastError =true, CharSet=CharSet.Unicode, ExactSpelling = true)]
private static extern IntPtr LoadLibraryW([MarshalAs(UnmanagedType.LPWStr)] string fileName);
[DllImport("kernel32.dll", CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
private static extern IntPtr LoadLibraryExW([MarshalAs(UnmanagedType.LPWStr)] string fileName, IntPtr reserved, UInt32 flags);
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling =true)]
private static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
private const UInt32 LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x0100;
private const UInt32 LOAD_LIBRARY_DEFAULT_DIRS = 0x1000;
public static DxcCreateInstanceFn LoadDxcCreateInstance(string dllPath, string fnName)
{
IntPtr handle = LoadLibraryW(dllPath);
UInt32 flags = LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_DEFAULT_DIRS;
IntPtr handle = LoadLibraryExW(dllPath, IntPtr.Zero, flags);
if (handle == IntPtr.Zero)
{
throw new System.ComponentModel.Win32Exception();