示例#1
0
    public void MarshalInterface(ImmIStream pStm, ref Guid riid, IntPtr pv, uint dwDestContext, IntPtr pvDestContext, uint mshlflags)
    {
        Console.WriteLine(">> " + GetCurrentMethod());
        uint count_written;

        pStm.Write(new byte[] { 0x00, 0x00 }, 2, out count_written);
        Random random = new Random();

        pStm.Write(new byte[] { (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255) }, 10, out count_written);

        pStm.Write(qc_mi_guid.ToByteArray(), 16, out count_written);
        pStm.Write(new byte[] { (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255) }, 4, out count_written);
        pStm.Write(composite_moniker_guid.ToByteArray(), 16, out count_written);
        pStm.Write(new byte[] { 0x02, 0x00, 0x00, 0x00 }, 4, out count_written);

        ComTypes.IBindCtx bind_context;
        ImmIMoniker       file_moniker = null;
        object            new_moniker  = null;

        uint CLSCTX_ALL = (uint)CLSCTX.CLSCTX_INPROC_SERVER | (uint)CLSCTX.CLSCTX_INPROC_HANDLER | (uint)CLSCTX.CLSCTX_LOCAL_SERVER | (uint)CLSCTX.CLSCTX_REMOTE_SERVER;

        ImmComTypes.CreateBindCtx(0, out bind_context);
        string sct_path = "SCT_PATH";

        ImmComTypes.CreateFileMoniker(sct_path,
                                      out file_moniker);
        ImmComTypes.CoCreateInstance(new_moniker_guid,
                                     IntPtr.Zero,
                                     CLSCTX_ALL,
                                     iunknown_guid,
                                     out new_moniker);

        ImmComTypes.OleSaveToStream((ImmIPersistStream)file_moniker, pStm);
        ImmComTypes.OleSaveToStream((ImmIPersistStream)new_moniker, pStm);
    }
示例#2
0
 public static extern int CreateFileMoniker([MarshalAs(UnmanagedType.LPWStr)] string lpszPathName, out ImmIMoniker ppmk);
示例#3
0
 public static extern int CreateGenericComposite(ImmIMoniker pmkFirst,
                                                 ImmIMoniker pmkRest,
                                                 out ImmIMoniker ppmkComposite);