ILockBytes

For calling:

[ComVisible(false)]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("0000000A-0000-0000-C000-000000000046")]
public interface ILockBytes
{
    //Note: These two by(reference 32-bit integers (ULONG) could be used as return values instead,
    //      but they are not tagged [retval] in the IDL, so for consitency's sake...
    void ReadAt(long ulOffset, System.IntPtr pv, int cb, out System.UInt32 pcbRead);
    void WriteAt(long ulOffset, System.IntPtr pv, int cb, out System.UInt32 pcbWritten);
    void Flush();
    void SetSize(long cb);
    void LockRegion(long libOffset, long cb, int dwLockType);
    void UnlockRegion(long libOffset, long cb, int dwLockType);
    void Stat(out System.Runtime.InteropServices.STATSTG pstatstg, int grfStatFlag);

}

For implementing:

[ComVisible(false)]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("0000000A-0000-0000-C000-000000000046")]
public interface ILockBytes
{
    //Note: Cannot rely on these two as by-reference parameters, because they are tagged __out_opt in the headers:
    //      This means some caller could pass a null pointer instead
    void ReadAt(long ulOffset, System.IntPtr pv, int cb, System.IntPtr pcbRead);
    void WriteAt(long ulOffset, System.IntPtr pv, int cb, System.IntPtr pcbWritten);
    void Flush();
    void SetSize(long cb);
    //Just ThrowExceptionForHR(STG_E_INVALIDFUNCTION) if locking is not supported.
    //Define it as a constant with the value unchecked((int)0x80030001u)
    void LockRegion(long libOffset, long cb, int dwLockType);
    void UnlockRegion(long libOffset, long cb, int dwLockType);
    void Stat(out System.Runtime.InteropServices.STATSTG pstatstg, int grfStatFlag);

}

For implementing:

Notes:

Última actualización