Exemplo n.º 1
0
        private static int Open(string filePath, DatabaseOpenMode mode)
        {
            if (String.IsNullOrEmpty(filePath))
            {
                throw new ArgumentNullException("filePath");
            }

            if (Path.GetExtension(filePath).Equals(".msp", StringComparison.Ordinal))
            {
                const int DATABASEOPENMODE_PATCH = 32;
                int       patchMode = (int)mode | DATABASEOPENMODE_PATCH;
                mode = (DatabaseOpenMode)patchMode;
            }

            int  hDb;
            uint ret = NativeMethods.MsiOpenDatabase(filePath, (IntPtr)mode, out hDb);

            if (ret != 0)
            {
                throw InstallerException.ExceptionFromReturnCode(
                          ret,
                          String.Format(CultureInfo.InvariantCulture, "Database=\"{0}\"", filePath));
            }
            return(hDb);
        }
Exemplo n.º 2
0
        private static int Open(string filePath, string outputPath)
        {
            if (String.IsNullOrEmpty(filePath))
            {
                throw new ArgumentNullException("filePath");
            }

            if (String.IsNullOrEmpty(outputPath))
            {
                throw new ArgumentNullException("outputPath");
            }

            int  hDb;
            uint ret = NativeMethods.MsiOpenDatabase(filePath, outputPath, out hDb);

            if (ret != 0)
            {
                throw InstallerException.ExceptionFromReturnCode(ret);
            }
            return(hDb);
        }