// Methods internal StatPropSetStgCollection(IPropertySetStorage propertySetStorage) { StatPropSetStg Stat; int fetched; IEnumSTATPROPSETSTG oEnum = propertySetStorage.Enum(); Label_0024: fetched = 0; if (oEnum.Next(1, out Stat, out fetched) == 0) { base.InnerList.Add(Stat); goto Label_0024; } Marshal.ReleaseComObject(oEnum); }
public static IEnumerable <STATPROPSETSTG> AsEnumerable(this IPropertySetStorage propertySetStorage) { FoundationContract.Requires <ArgumentException>(propertySetStorage != null); IEnumSTATPROPSETSTG enumStatPropSetStg; propertySetStorage.Enum(out enumStatPropSetStg); while (true) { var statPropSetStgArray = new STATPROPSETSTG[1]; uint fetched; enumStatPropSetStg.Next(1, statPropSetStgArray, out fetched); if (fetched == 0) { break; } yield return(statPropSetStgArray[0]); } }
private void LoadPropertySets() { HRESULT hr = (int)HRESULT.E_FAIL; IEnumSTATPROPSETSTG enumerator = null; STATPROPSETSTG[] stat = new STATPROPSETSTG[1]; uint fetched = 0; List <Guid> fmtids = new List <Guid>(); // Build list of FMTID's. try { if (NativeMethods.Succeeded(hr = _propertySetStorage.Enum(out enumerator))) { while (NativeMethods.Succeeded(hr = (enumerator.Next(1, stat, out fetched))) && (fetched == 1)) { fmtids.Add(stat[0].fmtid); } // IPropertySetStorage.Enum() does not enumerate FMTID_UserDefinedProperties. // Note that FMTID_UserDefinedProperties may not exist. fmtids.Add(FormatId.UserDefinedProperties); } foreach (Guid fmtid in fmtids) { Guid rfmtid = fmtid; uint grfMode = (uint)(STGM.READ | STGM.SHARE_EXCLUSIVE); //uint grfMode = (uint)(STGM.DIRECT | STGM.READ | STGM.SHARE_DENY_WRITE); IPropertyStorage propertyStorage = null; try { if (NativeMethods.Succeeded(hr = _propertySetStorage.Open(ref rfmtid, grfMode, out propertyStorage))) { _propertySets.Add(PropertySet.FromIPropertyStorage(propertyStorage)); } } catch { #if DEBUG System.Diagnostics.Debugger.Break(); #endif } finally { if (propertyStorage != null) { propertyStorage.FinalRelease(); } } } } catch { } finally { if (enumerator != null) { enumerator.FinalRelease(); } } }