示例#1
0
        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!");
            }
        }
示例#2
0
 public static extern IntPtr GetProcAddress(
     SafeLibraryHandle hModule,
     [MarshalAs(UnmanagedType.LPStr)] string procName);
示例#3
0
 protected void Dispose(bool disposing)
 {
     _libHandle.Close();
     _libHandle = null;
 }