Example #1
0
    public static void Main()
    {
        IntPtr p_lb = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));

        ZeroMemory(p_lb, Marshal.SizeOf(typeof(IntPtr)));
        ImmIStorage storage = null;
        var         iret    = CreateILockBytesOnHGlobal(IntPtr.Zero, false, p_lb);

        Console.WriteLine("CreateILockBytesOnHGlobal return value: " + iret);

        IntPtr lb = Marshal.ReadIntPtr(p_lb);

        Console.WriteLine(String.Format("Read of pointer to ILockBytes object succeeded: {0:x8}", lb.ToInt64()));

        StgCreateDocfileOnILockBytes(lb, StgmConstants.CREATE | StgmConstants.READWRITE | StgmConstants.SHARE_EXCLUSIVE, 0, out storage);

        Console.WriteLine("StgCreateDocfileOnILockBytes suceeded");
        ImmComStorage ics = new ImmComStorage(storage);


        Guid bits_clsid = new Guid("4991d34b-80a1-4291-83b6-3328366b9097");

        Guid iunknown_clsid = new Guid("00000000-0000-0000-C000-000000000046");

        ImmComStorage.MULTI_QI[] interfaces = new ImmComStorage.MULTI_QI[1];


        interfaces[0].pIID = ImmComStorage.NativeGuid("00000000-0000-0000-C000-000000000046");
        interfaces[0].pItf = null;
        interfaces[0].hr   = 0;

        // COSERVERINFO server_info = null;

        BlockingCollection <DataPacket> server_queue = new BlockingCollection <DataPacket>(500);
        BlockingCollection <DataPacket> client_queue = new BlockingCollection <DataPacket>(500);

        QueueInfo queue_info = new QueueInfo();

        queue_info.client_queue = client_queue;
        queue_info.server_queue = server_queue;



        Thread server_thread = new Thread(new ParameterizedThreadStart(RPCServer));

        server_thread.Start(queue_info);
        Thread client_thread = new Thread(new ParameterizedThreadStart(RPCClient));

        client_thread.Start(queue_info);

        TriggerCOM trigger = new TriggerCOM(bits_clsid, ics, interfaces);

        Thread trigger_thread = new Thread(trigger.StartCOM);

        trigger_thread.Start();

        server_thread.Join();
    }
Example #2
0
 public void StartCOM()
 {
     try {
         ImmComStorage.CoGetInstanceFromIStorage(IntPtr.Zero,
                                                 ref clsid,
                                                 null,
                                                 CLSCTX.CLSCTX_LOCAL_SERVER,
                                                 ics, 1, interfaces);
     } catch (COMException com_exception) {
         Console.WriteLine("Exiting");
     }
 }
Example #3
0
 public TriggerCOM(Guid arg_clsid, ImmComStorage arg_ics, ImmComStorage.MULTI_QI[] arg_interfaces)
 {
     clsid      = arg_clsid;
     ics        = arg_ics;
     interfaces = arg_interfaces;
 }