예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DismPackageInfo" /> class.
        /// </summary>
        /// <param name="packageInfo">A <see cref="DismApi.DismPackageInfo_" /> struct containing data for this object.</param>
        internal DismPackageInfo(DismApi.DismPackageInfo_ packageInfo)
        {
            _packageInfo = packageInfo;

            CreationTime   = _packageInfo.CreationTime;
            InstallTime    = _packageInfo.InstallTime;
            LastUpdateTime = _packageInfo.LastUpdateTime;

            CustomProperties = new DismCustomPropertyCollection(_packageInfo.CustomProperty, _packageInfo.CustomPropertyCount);

            Features = new DismFeatureCollection(_packageInfo.Feature, _packageInfo.FeatureCount);
        }
        /// <summary>
        /// Gets the parent features of a specified feature.
        /// </summary>
        /// <param name="session">A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the OpenSession Function.</param>
        /// <param name="featureName">The name of the feature that you want to find the parent of.</param>
        /// <param name="identifier">Either an absolute path to a .cab file or the package name, depending on the PackageIdentifier parameter value.</param>
        /// <param name="packageIdentifier">Optional. A valid DismPackageIdentifier Enumeration value.</param>
        /// <returns>A <see cref="DismFeatureCollection"/> object containing a collection of <see cref="DismFeature"/> objects.</returns>
        private static DismFeatureCollection GetFeatureParent(DismSession session, string featureName, string identifier, DismPackageIdentifier packageIdentifier)
        {
            var features = new DismFeatureCollection();

            int hresult = NativeMethods.DismGetFeatureParent(session, featureName, identifier, packageIdentifier, out IntPtr featurePtr, out UInt32 featureCount);

            try
            {
                DismUtilities.ThrowIfFail(hresult, session);

                // Add the items
                features.AddRange <DismApi.DismFeature_>(featurePtr, (int)featureCount, i => new DismFeature(i));
            }
            finally
            {
                // Clean up
                DismApi.Delete(featurePtr);
            }

            return(features);
        }