Skip to content

Commit 8e2092e

Browse files
dellis1972grendello
authored andcommitted
Added Support for loading the 64bit libzip.dll on Windows. (#10)
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
1 parent 61ad78f commit 8e2092e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Native.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,18 @@ public static long zip_source_make_command_bitmap (params SourceCommand[] cmd)
271271
}
272272
return bitmap;
273273
}
274+
275+
[DllImport ("kernel32.dll", SetLastError = true)]
276+
private static extern bool SetDllDirectory (string lpPathName);
277+
278+
static Native ()
279+
{
280+
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
281+
string executingDirectory = System.IO.Path.GetDirectoryName (typeof(Native).Assembly.Location);
282+
if (Environment.Is64BitProcess) {
283+
SetDllDirectory (System.IO.Path.Combine (executingDirectory, "x64"));
284+
}
285+
}
286+
}
274287
}
275288
}

0 commit comments

Comments
 (0)