// Return true if a compound document is enforcing read-only // Looks in the Summary Information stream private static bool IsCDFReadOnlyEnforced(string filename) { using (CompoundFile cf = new CompoundFile(fileName: filename, updateMode: CFSUpdateMode.ReadOnly, configParameters: CFSConfiguration.Default)) { if (null == cf) { return(false); } CFStream summaryInfo = cf.RootStorage.GetStream("\x05SummaryInformation"); if (null != summaryInfo) { // Interested in the doc security setting OpenMcdf.Extensions.OLEProperties.PropertySetStream ps = null; try { ps = summaryInfo.AsOleProperties(); } catch (Exception) { // There may be no properties for us to get return(false); } int securityIdx = ps.PropertySet0.PropertyIdentifierAndOffsets.FindIndex(x => x.PropertyIdentifier == OpenMcdf.Extensions.OLEProperties.PropertyIdentifiersSummaryInfo.PidsiDocSecurity); if (securityIdx >= 0 && securityIdx < ps.PropertySet0.Properties.Count) { int security = (int)ps.PropertySet0.Properties[securityIdx].PropertyValue; // See if read-only is enforced https://msdn.microsoft.com/en-us/library/windows/desktop/aa371587(v=vs.85).aspx if ((security & 4) == 4) { return(true); } } } return(false); } }