public static VCSolutionOptions Read(string InputFileName)
        {
            IOleStorage Storage = null;

            StgOpenStorage(InputFileName, null, STGM.Direct | STGM.Read | STGM.ShareExclusive, IntPtr.Zero, 0, out Storage);
            try
            {
                IOleEnumSTATSTG Enumerator = null;
                Storage.EnumElements(0, IntPtr.Zero, 0, out Enumerator);
                try
                {
                    uint      Fetched;
                    STATSTG[] Stats = new STATSTG[200];
                    Enumerator.Next((uint)Stats.Length, Stats, out Fetched);

                    VCSolutionOptions Options = new VCSolutionOptions();
                    foreach (STATSTG Stat in Stats)
                    {
                        if (Stat.pwcsName == "SolutionConfiguration")
                        {
                            IOleStream OleStream;
                            Storage.OpenStream(Stat.pwcsName, IntPtr.Zero, STGM.Read | STGM.ShareExclusive, 0, out OleStream);
                            try
                            {
                                uint   SizeRead;
                                byte[] Buffer = new byte[Stat.cbSize];
                                OleStream.Read(Buffer, (uint)Stat.cbSize, out SizeRead);

                                using (MemoryStream InputStream = new MemoryStream(Buffer, false))
                                {
                                    BinaryReader Reader = new BinaryReader(InputStream, Encoding.Unicode);
                                    while (InputStream.Position < InputStream.Length)
                                    {
                                        Options.SolutionConfiguration.Add(VCBinarySetting.Read(Reader));
                                    }
                                }
                            }
                            finally
                            {
                                Marshal.ReleaseComObject(OleStream);
                            }
                        }
                    }
                    return(Options);
                }
                finally
                {
                    Marshal.ReleaseComObject(Enumerator);
                }
            }
            finally
            {
                Marshal.ReleaseComObject(Storage);
            }
        }
Beispiel #2
0
 public IEnumerable <VCBinarySetting> GetConfiguration()
 {
     byte[] Data;
     if (TryGetSection("SolutionConfiguration", out Data))
     {
         using (MemoryStream InputStream = new MemoryStream(Data, false))
         {
             BinaryReader Reader = new BinaryReader(InputStream, Encoding.Unicode);
             while (InputStream.Position < InputStream.Length)
             {
                 yield return(VCBinarySetting.Read(Reader));
             }
         }
     }
 }