Пример #1
0
        internal static int GetPropertyName(this IPropertyStorage propertyStorage, uint propid, out string name)
        {
            HRESULT hr = HRESULT.E_FAIL;

            name = String.Empty;

            uint[]   rgpropid     = { propid };
            string[] rglpwstrName = { String.Empty };

            if (NativeMethods.Succeeded(hr = propertyStorage.ReadPropertyNames(1, rgpropid, rglpwstrName)))
            {
                name = rglpwstrName[0];
            }

            if (String.IsNullOrWhiteSpace(name))
            {
                Guid fmtid = propertyStorage.GetFormatId();

                if (fmtid.Equals(FormatId.SummaryInformation))
                {
                    name = propertyStorage.GetPropertyName((PIDSI)propid);
                    hr   = HRESULT.S_OK;
                }
                else if (fmtid.Equals(FormatId.DocSummaryInformation))
                {
                    name = propertyStorage.GetPropertyName((PIDDSI)propid);
                    hr   = HRESULT.S_OK;
                }
            }

            return(hr);
        }