开发者

ActiveX in HTML

开发者 https://www.devze.com 2023-04-09 04:00 出处:网络
My requirement is to instantiate an object using new ActiveX() in html. I have created a COM component SimpleActiveX using ATL. I have created the dll SimpleActiveX.dll for the same. In order to inst

My requirement is to instantiate an object using new ActiveX() in html.

I have created a COM component SimpleActiveX using ATL. I have created the dll SimpleActiveX.dll for the same. In order to instantiate this component in html file I need to register the dll. So I registered the dll using the command regsvr32 %Path of dll%. After doing so I am trying to create and instance of the component in html file as follows,

var req;
req = new ActiveX("SimpleActiveX.Hello"); //Assume Hello as a class.
req.Hi(); //Assume that Hi() is a member function of Hello.

By doing so I am unable to create the ActiveX object. Html doesnt give any error too. I dont know whether I am doing anything wrong or am I missing anything.

Could anyone please tell me the proper steps to perform above operations.

开发者_C百科

How do I need to create the dll (Here in this case I have just build the ATL project in Visual Studio to generate the dll)?

What else do I need to do with the dll in case if I need to create an ActiveX object in html?

I had come across something called as <object> </object> tag in html where we mention the classid and attributes. I dont know whether I need to mention this in my html file or not.

Thanks for your help in advance.


To instantiate an ActiveX object in JavaScript, assuming the dll is correctly registered, you just have to use:

var req = new ActiveXObject("SimpleActiveX.Hello");

Unfortunately I don't know how to register a dll using Visual Studio.

Regarding the tag, it is used when you want to embed the object directly in your HTML code, so that it will be instantiated when the document loads, instead of using JavaScript.

For example:

<object id="myObject" classid="CLSID:2D360200-FFF5-11D1-8D03-00A0C959BC0A"></object>

Then you can access the COM object with

var myObject = document.getElementById("myObject").object
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号