This is a mirror of official site: http://jasper-net.blogspot.com/

Creating a simple COM+ component in C++

| Sunday, October 17, 2010
Introduction
I needed to test .NET com interoperability (as all debugging APIs are written in COM+) and so decided to implement my own simple COM+ component and then use it in my .NET application. I must warn you that I just started learning COM so if you are going to use this code you need to be careful  . As I’m a big fan of Starcraft II this component will implement objects representing Nexus (Protoss main building) and Probe (Protoss harvester) – more info here. Probes can build Nexuses and Nexuses create Probes. We will have then two interfaces (INexus, IProbe) and their CoClasses (Nexus, Probe).

IDL definition:

import "unknwn.idl";

[object, uuid(C5F45CBC-4439-418C-A9F9-05AC67525E43)]
interface INexus : IUnknown
{
 HRESULT CreateUnit(
   [in]  REFCLSID rclsid,
   [in]  REFIID   riid,
   [out, iid_is(riid), retval] LPVOID *ppUnk);
}

[object, uuid(246A22D5-CF02-44B2-BF09-AAB95A34E0CF)]
interface IProbe : IUnknown
{
 HRESULT ConstructBuilding(
   [in] REFCLSID rclsid,
   [in] REFIID riid,
   [out, iid_is(riid), retval] LPVOID *ppUnk);
}

Read more: Low level design

Posted via email from .NET Info

0 comments: