Unmanaged C++ Example

Import type libraries:

#import "NGSystem.tlb" no_namespace 
#import "genericclass.dll" no_namespace 
#import "C:\SAMPLE\Release\SAMPLE\Core\Bin\SAMPLE_.tlb" no_namespace

Initialise COM libraries

HRESULT hr = ::CoInitialize(NULL);

Define the ISegmentCycle COM interface pointer and create an instance of the Segment component. In this case we are connecting to the SAMPLE.1 component (the Segment component for the SAMPLE application). The exact name of the component can be found by expanding the COM+ application in Component Services.

CComPtr<ISegmentCycle> pSegment; 
pSegment.CoCreateInstance( L"SAMPLE" ); 
CComQIPtr<I_SAMPLE>pSAMPLE(pSegment);

Call the method:

_bstr_t CustomerId = L"123456";
_bstr_t CustName = L"John Smith";
pSAMPLE->AddCustomer(CustomerId, CustName);