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
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.