Runtime Callable Wrapper (RCW)

This wrapper turns the COM interfaces exposed by the COM component into .NET-compatible interfaces. For oleautomation interfaces, the RCW can be generated automatically from a type library. For non-oleautomation interfaces, it may be necessary to develop a custom RCW which manually maps the types exposed by the COM interface to .NET-compatible types.
1. create an ATL component which implements the following IDL
2. tlbimp cppcomserver.tlb
using System;
public class MainApp
static public void Main()
CppName cppname = new CppName();
cppname.SetName( “bob” );
Console.WriteLine( “Name is ” + cppname.GetName() );

4. csc /r:cppcomserverlib.dll csharpcomclient.cs

eg of TLB file:

import “oaidl.idl”;
import “ocidl.idl”;
[ object, uuid(EA013F93-487A-4403-86EC-FD9FEE5E6206), helpstring(“ICppName Interface”), pointer_default(unique), oleautomation ]
interface ICppName : IUnknown { [helpstring(“method SetName”)] HRESULT SetName([in] BSTR name); [helpstring(“method GetName”)] HRESULT GetName([out,retval] BSTR *pName ); }; [ uuid(F5E4C61D-D93A-4295-A4B4-2453D4A4484D), version(1.0), helpstring(“cppcomserver 1.0 Type Library”) ] library CPPCOMSERVERLib { importlib(“stdole32.tlb”); importlib(“stdole2.tlb”); [ uuid(600CE6D9-5ED7-4B4D-BB49-E8D5D5096F70), helpstring(“CppName Class”) ] coclass CppName { [default] interface ICppName; }; };


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s