本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例5: WICReadOnlyStreamWrapper
public WICReadOnlyStreamWrapper(IStream stream)
{
this.stream = stream;
stream.Stat(out stat, 1);
}
示例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);
}
}