SevenZip/LibraryManager.cs
/// <summary>
///   Loads the 7-zip library if necessary and adds user to the reference list
/// </summary>
/// <param name = "user">Caller of the function</param>
/// <param name = "format">Archive format</param>
Loads the 7-zip library if necessary and adds user to the reference list
Loads the 7 - zip library if necessary and adds user to the reference list
public static void LoadLibrary(object user, Enum format)
        {
            if (_inArchives == null
#if COMPRESS
                || _outArchives == null
#endif
                )
            {
                Init();
            }
#if !WINCE && !MONO
            if (_modulePtr == IntPtr.Zero)
            {
                if (!File.Exists(_libraryFileName))
                {
                    throw new SevenZipLibraryException("DLL file does not exist.");
                }
                if ((_modulePtr = NativeMethods.LoadLibrary(_libraryFileName)) == IntPtr.Zero)
                {
                    throw new SevenZipLibraryException("failed to load library.");
                }
                if (NativeMethods.GetProcAddress(_modulePtr, "GetHandlerProperty") == IntPtr.Zero)
                {
                    NativeMethods.FreeLibrary(_modulePtr);
                    throw new SevenZipLibraryException("library is invalid.");
                }
            }
#endif
            if (format is InArchiveFormat)
            {
                InitUserInFormat(user, (InArchiveFormat) format);
                return;
            }
#if COMPRESS
            if (format is OutArchiveFormat)
            {
                InitUserOutFormat(user, (OutArchiveFormat) format);
                return;
            }
#endif
            throw new ArgumentException(
                "Enum " + format + " is not a valid archive format attribute!");
        }
public static void LoadLibrary ( object user , Enum format ) { if ( _inArchives == null if COMPRESS || _outArchives == null endif ) { Init ( ) ; } if ! WINCE && ! MONO if ( _modulePtr == IntPtr . Zero ) { if ( ! File . Exists ( _libraryFileName ) ) { throw new SevenZipLibraryException ( " " ) ; } if ( ( _modulePtr = NativeMethods . LoadLibrary ( _libraryFileName ) ) == IntPtr . Zero ) { throw new SevenZipLibraryException ( " " ) ; } if ( NativeMethods . GetProcAddress ( _modulePtr , " " ) == IntPtr . Zero ) { NativeMethods . FreeLibrary ( _modulePtr ) ; throw new SevenZipLibraryException ( " " ) ; } } endif if ( format is InArchiveFormat ) { InitUserInFormat ( user , ( InArchiveFormat ) format ) ; return ; } if COMPRESS if ( format is OutArchiveFormat ) { InitUserOutFormat ( user , ( OutArchiveFormat ) format ) ; return ; } endif throw new ArgumentException ( " " + format + " " ) ; }
Loads the 7-zip library if necessary and adds user to the reference list
Loads the 7 - zip library if necessary and adds user to the reference list
user
object
Caller of the function
Caller of the function
format
Enum
None