Chinaunix首页 | 论坛 | 博客
  • 博客访问: 444085
  • 博文数量: 96
  • 博客积分: 6045
  • 博客等级: 大校
  • 技术积分: 906
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-03 11:29
文章分类

全部博文(96)

文章存档

2014年(1)

2012年(22)

2011年(23)

2010年(31)

2008年(1)

2007年(18)

分类: C/C++

2011-05-19 14:32:00

这几天学习COM组件,先用VB调用DLL:
  1. Private Sub Form_Load()
  2. Set myObj = CreateObject("IExample2.object")
  3. myObj.SetString ("Hello world")
  4. Copy = myObj.GetString()
  5. MsgBox Copy, 0, "GetString return"
  6. End Sub

测试调用成功!
但有一点小小的疑问:当输入对象名后,不能自动弹出该对象的方法与属性(到论坛上咨询,基本上说是VB编译器的问题),我至今也没弄明白原因!?
随后在javascript脚本中测试该组件:
  1. <html xmlns="">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  4. <title>Untitled Document</title>
  5. </head>
  6. <body>
  7. <object classid="clsid:520F4CFD-61C6-4EED-8004-C26D514D3D19" id="IExample2.object" width="286" height="225">                  
  8. </object>
  9. <script language="JavaScript">
  10.    var myObj ;
  11.    myObj = document.getElementById("IExample2.object");
  12.    myObj .SetString ("Hello world")
  13.    alert(myObj.GetString ())
  14. </script>
  15. </body>
  16. </html>
测试也成功!
但还是有个问题,那就是采用下面的方式就不成功,是什么原因?
  1. <html xmlns="">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  4. <title>Untitled Document</title>
  5. </head>
  6. <body>
  7. <script language="JavaScript">
  8.    var myObj= new ActiveXObject("IExample2.object")
  9.    myObj.SetString ("Hello world")
  10.    Copy = myObj.GetString()
  11.    alert(Copy)
  12. </script>
  13. </body>
  14. </html>


阅读(4158) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~