Multiple IDispatch implementations

I was designing a simple COM based scriptable DirectX framework, in C++ and ATL. I wanted to support multiple interfaces that were callable from JavaScript. Unfortunately, scripting clients cannot access interfaces that are not marked default. One way of handling this was to make my automation compatible interface a super set of all the interfaces that I was going to implement in my coclasses. that just didn’t seem right, and wouldn’t work with coclasses that were aggregated, because the scripting client couldn’t find the aggregated interface.

So I googled the problem and came across this and this that seemed to be relevant.  Chris Sells’ page about multiple IDispatch implementations listed about 5 ways to do this. However, out of all the methods listed only one of them worked without modifying the component. [Method 5 on this Page]. Unfortunately, none of the references listed on the page weren’t working. So I set out to making my own implementation. Last night I finally got it to work properly. Here’s some sample JavaScript code.

var dispqi = new ActiveXObject(“MultiDispQI.CoDualInterfaceQuery”);
var dog = new ActiveXObject(“DogCatComponent.DogCat.1”);
dog.Bark();
var cat = dispqi.QueryInterface(dog,”DogCatComponent.DogCat.1″,”ICat”);
cat.Meow();
print();

Here is the source code.

Advertisements

2 Responses to Multiple IDispatch implementations

  1. […] In other news the QueryInterface for JScript for COM components has been uploaded. Posted in All Random Notes, Programming. […]

  2. Chris Sells says:

    Oh man is *that* a blast from the past! Sorry you have to go through that, man. : )

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: