当前位置: 首页>>代码示例>>C#>>正文


C# IStream.Stat方法代码示例

本文整理汇总了C#中IStream.Stat方法的典型用法代码示例。如果您正苦于以下问题:C# IStream.Stat方法的具体用法?C# IStream.Stat怎么用?C# IStream.Stat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IStream的用法示例。


在下文中一共展示了IStream.Stat方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetStreamSize

        private static int GetStreamSize(IStream stream)
        {
            const int STATFLAG_NONAME = 1;

            STATSTG stats;
            stream.Stat(out stats, STATFLAG_NONAME);
            long result = stats.cbSize;
            if (result < 0 || result > int.MaxValue)
            {
                throw new BadImageFormatException();
            }

            return (int)result;
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:14,代码来源:InteropUtilities.cs

示例2: GetAccessMode

		private static NativeMethods.Stgm GetAccessMode(IStream stream)
		{
			Debug.Assert(stream != null, "Expected stream.");

			try
			{
				// If IStream is created via CreateStreamOnHGlobal, stream.Stat() does not return the proper read/write state of the stream.
				// We bypass this by checking if it is created that way, and just return ReadWrite mode.
				IntPtr hStream;
				if (0 == NativeMethods.GetHGlobalFromStream(stream, out hStream) && hStream != IntPtr.Zero)
					return NativeMethods.Stgm.ReadWrite;

				// Get statistics from IStream.
				ComTypes.STATSTG stat;
				stream.Stat(out stat, (int)NativeMethods.STATFLAG.NoName);
				return (NativeMethods.Stgm)stat.grfMode;
			}
			catch (InvalidComObjectException ex)
			{
				throw new IOException(Resources.UnmanagedStream.IOException_StreamNotInitialized, ex);
			}
		}
开发者ID:skwasjer,项目名称:skwas.IO,代码行数:22,代码来源:UnmanagedStream.cs

示例3: PptStreamContainsEncryptedLabel

 static bool PptStreamContainsEncryptedLabel(IStream pptStream)
 {
     var ptrReadBytes = Marshal.AllocHGlobal(sizeof(ulong));
     try
     {
         int CHUNK_SIZE = 512;
         var lastChunk = new byte[CHUNK_SIZE];
         System.Runtime.InteropServices.ComTypes.STATSTG stat;
         pptStream.Stat(out stat, STATFLAG_DEFAULT);
         if (stat.cbSize > CHUNK_SIZE)
         {
             pptStream.Seek(stat.cbSize - CHUNK_SIZE, STREAM_SEEK_START, IntPtr.Zero);
         }
         pptStream.Read(lastChunk, CHUNK_SIZE, ptrReadBytes);
         var contentAsText = Encoding.ASCII.GetString(lastChunk);
         return contentAsText.Contains(ENCODED_LABEL_AS_TEXT);
     }
     finally
     {
         Marshal.FreeHGlobal(ptrReadBytes);
     }
 }
开发者ID:killbug2004,项目名称:WSProf,代码行数:22,代码来源:FileTypeIdentifier.cs

示例4: GetBufferFromIStream

        private static byte[] GetBufferFromIStream(IStream comStream)
        {
            LARGE_INTEGER zeroPos;
            zeroPos.QuadPart = 0;
            ULARGE_INTEGER[] streamPosition = new ULARGE_INTEGER[1];
            comStream.Seek(zeroPos, (uint)STREAM_SEEK.STREAM_SEEK_CUR, streamPosition);
            comStream.Seek(zeroPos, (uint)STREAM_SEEK.STREAM_SEEK_SET, null);

            Microsoft.VisualStudio.OLE.Interop.STATSTG[] stat = new Microsoft.VisualStudio.OLE.Interop.STATSTG[1];
            comStream.Stat(stat, (uint)STATFLAG.STATFLAG_NONAME);

            int bufferLength = (int)stat[0].cbSize.QuadPart;
            byte[] buffer = new byte[bufferLength];
            uint bytesRead = 0;
            comStream.Read(buffer, (uint)buffer.Length, out bytesRead);

            // return the stream to its previous location
            LARGE_INTEGER newPos;
            newPos.QuadPart = (long)streamPosition[0].QuadPart;
            comStream.Seek(newPos, (uint)STREAM_SEEK.STREAM_SEEK_SET, null);

            return buffer;
        }
开发者ID:Graham-Pedersen,项目名称:IronPlot,代码行数:23,代码来源:WindowPane.cs

示例5: WICReadOnlyStreamWrapper

 public WICReadOnlyStreamWrapper(IStream stream)
 {
     this.stream = stream;
     stream.Stat(out stat, 1);
 }
开发者ID:Rambalac,项目名称:LumixGH4WIC,代码行数:5,代码来源:WICStreamWrapper.cs

示例6: ParserProperties

        protected virtual void ParserProperties(IStorage storage, IStream propertyHeaderStream, ref int readCount)
        {
            STATSTG stat;
            propertyHeaderStream.Stat(out stat, 1);
            int count = (int)stat.cbSize;

            while (readCount < count)
            {
                var tag = propertyHeaderStream.ReadInt32(ref readCount);
                var flag = propertyHeaderStream.ReadInt32(ref readCount);
                var value = propertyHeaderStream.ReadInt64(ref readCount);
                IPropValueForParser property = SpecialPropertyUtil.Instance.CreateNewPropValue(tag, value);

                property.Parse(Storage);
                Properties.AddProperty(property);
            }
        }
开发者ID:haiyangIt,项目名称:Haiyang,代码行数:17,代码来源:BaseStruct.cs


注:本文中的IStream.Stat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。