From bf337cd1d394b86c7521a8f11f6f745f6500845d Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Tue, 5 Jul 2016 10:29:49 +0100 Subject: [PATCH] Added Support for loading the 64bit libzip.dll on Windows. Windows Apps can be either 32 or 64 bit. This commit uses the SetDllDirectory function to add a new search path to the current search paths so the correct 64 bit dll can be loaded. In this case it adds an "x64" directory which is relative to where the LibZipSharp assembly is. https://msdn.microsoft.com/en-us/library/ms686203(VS.85).aspx --- Native.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Native.cs b/Native.cs index cb389d46..e7fb41f4 100644 --- a/Native.cs +++ b/Native.cs @@ -271,5 +271,18 @@ public static long zip_source_make_command_bitmap (params SourceCommand[] cmd) } return bitmap; } + + [DllImport ("kernel32.dll", SetLastError = true)] + private static extern bool SetDllDirectory (string lpPathName); + + static Native () + { + if (Environment.OSVersion.Platform == PlatformID.Win32NT) { + string executingDirectory = System.IO.Path.GetDirectoryName (typeof(Native).Assembly.Location); + if (Environment.Is64BitProcess) { + SetDllDirectory (System.IO.Path.Combine (executingDirectory, "x64")); + } + } + } } }