Пример #1
0
        private static string GetPropertyName(Guid fmtid, IPropertyStorage propertyStorage, STATPROPSTG stg)
        {
            if (!string.IsNullOrEmpty(stg.lpwstrName))
            {
                return(stg.lpwstrName);
            }

            var propids = new uint[1];

            propids[0] = stg.propid;
            var names = new string[1];

            names[0] = null;
            var hr = propertyStorage.ReadPropertyNames(1, propids, names);

            if (hr == 0)
            {
                return(names[0]);
            }

            foreach (var kp in CompoundProperty.KnownProperties)
            {
                if (kp.FormatId == fmtid && kp.Id == stg.propid)
                {
                    return(kp.Name);
                }
            }
            return(null);
        }
Пример #2
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);
        }