Freigeben über


Interoperability of JScript with COM

Recently I worked on using COM component in JScript. I couldn't find one stop solution or example for this and so thought for writing series of posts regarding this.

Instantiating a COM class.

COM class should implement IDispatch and be registered with ProgID, so that JScript can invoke it using ActiveXObject semantics.

I used ATL library to create a ATL project called Sample and then added the Test which implements IDispatch and has progID = “Sample.Test”

Register this class using command

regsvr32 <path>Sample.dll

Now this class can be instantiated in JScript using:

var x = new ActiveXObject(“Sample.Test”);

Methods of Class Test can be invoked now using variable x.

I will talk about different mechanisms for passing parameters to and fro in next Posts.

Attached Zip contains the sample code.

Sample.zip

Comments

  • Anonymous
    September 25, 2007
    Here are links to a virtual series written by Sheetal, one of the developers in the JScript team on Jscript