Beispiel #1
0
        /// <summary>
        /// Calculates the disk space required by the feature and its selected children and parent features.
        /// </summary>
        /// <param name="includeParents">If true, the parent features are included in the cost.</param>
        /// <param name="includeChildren">If true, the child features are included in the cost.</param>
        /// <param name="installState">Specifies the installation state.</param>
        /// <returns>The disk space requirement in bytes.</returns>
        /// <remarks><p>
        /// Win32 MSI API:
        /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msigetfeaturecost.asp">MsiGetFeatureCost</a>
        /// </p></remarks>
        public long GetCost(bool includeParents, bool includeChildren, InstallState installState)
        {
            const int MSICOSTTREE_CHILDREN = 1;
            const int MSICOSTTREE_PARENTS  = 2;

            int  cost;
            uint ret = RemotableNativeMethods.MsiGetFeatureCost(
                (int)this.session.Handle,
                this.name,
                (includeParents ? MSICOSTTREE_PARENTS : 0) | (includeChildren ? MSICOSTTREE_CHILDREN : 0),
                (int)installState,
                out cost);

            if (ret != 0)
            {
                throw InstallerException.ExceptionFromReturnCode(ret);
            }
            return(cost * 512L);
        }