diff --git a/Emgu.CV/PInvoke/CvInvoke.cs b/Emgu.CV/PInvoke/CvInvoke.cs index ae92477a7..ab4d1a14d 100644 --- a/Emgu.CV/PInvoke/CvInvoke.cs +++ b/Emgu.CV/PInvoke/CvInvoke.cs @@ -305,8 +305,14 @@ namespace Emgu.CV String oldDir = Environment.CurrentDirectory; if (!String.IsNullOrEmpty(loadDirectory) && Directory.Exists(loadDirectory)) + { Environment.CurrentDirectory = loadDirectory; - + if (Emgu.Util.Platform.OperationSystem == Emgu.Util.Platform.OS.Windows) + { + bool setDllDirectorySuccess = Emgu.Util.Toolbox.SetDllDirectory(loadDirectory); + } + } + #endif System.Diagnostics.Debug.WriteLine(String.Format("Loading open cv binary from {0}", loadDirectory)); diff --git a/Emgu.Util/Toolbox.cs b/Emgu.Util/Toolbox.cs index 0d1395061..ebd32c434 100644 --- a/Emgu.Util/Toolbox.cs +++ b/Emgu.Util/Toolbox.cs @@ -548,8 +548,9 @@ namespace Emgu.Util { const int loadLibrarySearchDllLoadDir = 0x00000100; const int loadLibrarySearchDefaultDirs = 0x00001000; + const int loadLibrarySearchApplicationDir = 0x00000200; //const int loadLibrarySearchUserDirs = 0x00000400; - IntPtr handler = LoadLibraryEx(dllname, IntPtr.Zero, loadLibrarySearchDllLoadDir | loadLibrarySearchDefaultDirs); + IntPtr handler = LoadLibraryEx(dllname, IntPtr.Zero, loadLibrarySearchDllLoadDir | loadLibrarySearchDefaultDirs | loadLibrarySearchApplicationDir ); //IntPtr handler = LoadLibraryEx(dllname, IntPtr.Zero, loadLibrarySearchUserDirs); if (handler == IntPtr.Zero) {