예제 #1
0
        public static void Invoke(Func <MsiError> action)
        {
            MsiError res = action();

            if (res != MsiError.NoError)
            {
                throw new Exception(res.ToString());
            }
        }
예제 #2
0
        /// <summary>
        /// Determines whether the specified product code is installed.
        /// </summary>
        /// <param name="productCode">The product code.</param>
        /// <returns>Returns <c>true</c> if the product is installed. Otherwise returns <c>false</c>.</returns>
        public static bool IsInstalled(string productCode)
        {
            StringBuilder sb   = new StringBuilder(2048);
            uint          size = 2048;
            MsiError      err  = MsiInterop.MsiGetProductInfo(productCode, "InstallDate", sb, ref size);

            if (err == MsiError.UnknownProduct)
            {
                return(false);
            }
            else if (err == MsiError.NoError)
            {
                return(true);
            }
            else
            {
                throw new Exception(err.ToString());
            }
        }