Beispiel #1
0
        protected void LoadLibrary(string dllPath)
        {
            // Try to locate dlls in the current directory (for libretro cores),
            // this isn't foolproof but it's a little better than nothing.
            string path = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Process);

            try
            {
                string assemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                string dllDirectory      = Path.GetDirectoryName(dllPath);
                string alteredPath       = string.Format("{0};{1};{2}", assemblyDirectory, dllDirectory, path);
                Environment.SetEnvironmentVariable("PATH", alteredPath, EnvironmentVariableTarget.Process);
                _hModule = NativeMethods.LoadLibrary(dllPath);
                if (_hModule.IsInvalid)
                {
                    int hr = Marshal.GetHRForLastWin32Error();
                    Marshal.ThrowExceptionForHR(hr);
                }
            }
            finally
            {
                Environment.SetEnvironmentVariable("PATH", path, EnvironmentVariableTarget.Process);
            }
        }
Beispiel #2
0
 public static extern IntPtr GetProcAddress(SafeLibraryHandle hModule, string procedureName);