internal SevenZipLibrary(string sevenZipLibPath) { if (!File.Exists(sevenZipLibPath)) { throw new FileNotFoundException("Required file not found.", sevenZipLibPath); } _libHandle = NativeMethods.LoadLibrary(sevenZipLibPath); if (_libHandle.IsInvalid) { throw new Win32Exception("LoadLibrary call for 7z.dll failed: invalid handle!"); } IntPtr functionPtr = NativeMethods.GetProcAddress(_libHandle, "GetHandlerProperty"); if (functionPtr == IntPtr.Zero) { _libHandle.Close(); throw new ArgumentException("7z library: invalid DLL!"); } }
public static extern IntPtr GetProcAddress( SafeLibraryHandle hModule, [MarshalAs(UnmanagedType.LPStr)] string procName);
protected void Dispose(bool disposing) { _libHandle.Close(); _libHandle = null; }