예제 #1
0
        public void InitializeSimple(DismLogLevel logLevel)
        {
            DismApi.Initialize(logLevel);

            try
            {
            }
            finally
            {
                DismApi.Shutdown();
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes DISM API. Initialize must be called once per process before calling any other DISM API functions.
        /// </summary>
        /// <param name="logLevel">Indicates the level of logging.</param>
        /// <param name="logFilePath">A relative or absolute path to a log file. All messages generated will be logged to this path. If NULL, the default log path, %windir%\Logs\DISM\dism.log, will be used.</param>
        /// <param name="scratchDirectory">A relative or absolute path to a scratch directory. DISM API will use this directory for internal operations. If null, the default temp directory, \Windows\%Temp%, will be used.</param>
        /// <exception cref="DismException">When a failure occurs.</exception>
        public static void Initialize(DismLogLevel logLevel, string logFilePath, string scratchDirectory)
        {
            lock (InitializeShutDownLock)
            {
                if (!_isInitialized)
                {
                    int hresult = NativeMethods.DismInitialize(logLevel, logFilePath, scratchDirectory);

                    DismUtilities.ThrowIfFail(hresult);

                    _isInitialized = true;
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Initializes DISM API, using the specified DISM Generation. Initialize must be called once per process before calling any other DISM API functions.
        /// </summary>
        /// <param name="logLevel">Indicates the level of logging.</param>
        /// <param name="logFilePath">A relative or absolute path to a log file. All messages generated will be logged to this path. If NULL, the default log path, %windir%\Logs\DISM\dism.log, will be used.</param>
        /// <param name="scratchDirectory">A relative or absolute path to a scratch directory. DISM API will use this directory for internal operations. If null, the default temp directory, \Windows\%Temp%, will be used.</param>
        /// <param name="dismGeneration">The DISM Generational Library to be used.</param>
        /// /// <exception cref="Exception">If an error occurs loading the latest DISM Generational Library.</exception>
        /// <exception cref="DismException">When a failure occurs.</exception>
        public static void InitializeEx(DismLogLevel logLevel, string logFilePath, string scratchDirectory, DismGeneration dismGeneration)
        {
            if (CurrentDismGeneration != DismGeneration.NotFound)
            {
                throw new Exception($"A DISM Generation library is already loaded ({dismGeneration}). Please call Shutdown() first to release the existing library.");
            }

            if (dismGeneration != DismGeneration.NotFound && !DismUtilities.LoadDismGenerationLibrary(dismGeneration))
            {
                throw new Exception($"Loading the latest DISM Generation library ({dismGeneration}) failed.");
            }

            DismApi.Initialize(logLevel, logFilePath, scratchDirectory);

            CurrentDismGeneration = dismGeneration;
        }
예제 #4
0
 public static extern void DismInitialize(
     DismLogLevel logLevel,
     [CanBeNull] string logFilePath,
     [CanBeNull] string scratchDirectory
     );
예제 #5
0
 public static extern int DismInitialize(DismLogLevel logLevel, string logFilePath, string scratchDirectory);
예제 #6
0
 /// <summary>
 /// Initializes DISM API. Initialize must be called once per process before calling any other DISM API functions.
 /// </summary>
 /// <param name="logLevel">Indicates the level of logging.</param>
 /// <param name="logFilePath">A relative or absolute path to a log file. All messages generated will be logged to this path. If NULL, the default log path, %windir%\Logs\DISM\dism.log, will be used.</param>
 /// <exception cref="DismException">When a failure occurs.</exception>
 public static void Initialize(DismLogLevel logLevel, string logFilePath)
 {
     Initialize(logLevel, logFilePath, null);
 }
예제 #7
0
 /// <summary>
 /// Initializes DISM API. Initialize must be called once per process before calling any other DISM API functions.
 /// </summary>
 /// <param name="logLevel">Indicates the level of logging.</param>
 /// <exception cref="DismException">When a failure occurs.</exception>
 public static void Initialize(DismLogLevel logLevel)
 {
     Initialize(logLevel, null);
 }
예제 #8
0
 /// <summary>
 /// Initializes DISM API, using the latest installed DISM Generation. Initialize must be called once per process before calling any other DISM API functions.
 /// </summary>
 /// <param name="logLevel">Indicates the level of logging.</param>
 /// <param name="logFilePath">A relative or absolute path to a log file. All messages generated will be logged to this path. If NULL, the default log path, %windir%\Logs\DISM\dism.log, will be used.</param>
 /// <exception cref="Exception">If an error occurs loading the latest DISM Generational Library.</exception>
 /// <exception cref="DismException">When a failure occurs.</exception>
 public static void InitializeEx(DismLogLevel logLevel, string logFilePath)
 {
     InitializeEx(logLevel, logFilePath, null, DismUtilities.GetLatestDismGeneration());
 }
예제 #9
0
 /// <summary>
 /// Initializes DISM API, using the latest installed DISM Generation. Initialize must be called once per process before calling any other DISM API functions.
 /// </summary>
 /// <param name="logLevel">Indicates the level of logging.</param>
 /// <exception cref="Exception">If an error occurs loading the latest DISM Generational Library.</exception>
 /// <exception cref="DismException">When a failure occurs.</exception>
 public static void InitializeEx(DismLogLevel logLevel)
 {
     InitializeEx(logLevel, null, null, DismUtilities.GetLatestDismGeneration());
 }
예제 #10
0
 /// <summary>
 /// Initializes DISM API, using the latest installed DISM Generation. Initialize must be called once per process before calling any other DISM API functions.
 /// </summary>
 /// <param name="logLevel">Indicates the level of logging.</param>
 /// <param name="logFilePath">A relative or absolute path to a log file. All messages generated will be logged to this path. If NULL, the default log path, %windir%\Logs\DISM\dism.log, will be used.</param>
 /// <param name="scratchDirectory">A relative or absolute path to a scratch directory. DISM API will use this directory for internal operations. If null, the default temp directory, \Windows\%Temp%, will be used.</param>
 /// /// <exception cref="Exception">If an error occurs loading the latest DISM Generational Library.</exception>
 /// <exception cref="DismException">When a failure occurs.</exception>
 public static void InitializeEx(DismLogLevel logLevel, string logFilePath, string scratchDirectory)
 {
     InitializeEx(logLevel, logFilePath, scratchDirectory, DismUtilities.GetLatestDismGeneration());
 }
 public static extern int DismInitialize(DismLogLevel LogLevel, [MarshalAs(UnmanagedType.LPWStr)] string LogFilePath, [MarshalAs(UnmanagedType.LPWStr)] string ScratchDirectory);