关于VBScript调用COM组件的问题?
有一个COM组件, 支持事件, 我使用VBScript编写了一个简单的脚本文件(.vbs)在控制台使用wscript.exe执行,能够创建并正确执行组件的方法与属性,但是还想使用这个组件的事件, 但是没有找到相关的方法, 请教各位, 最好能有个例子代码, 谢谢了:)
[解决办法]
COM的CONNECTION POINT能成为一种事件发生回调机制。
VBS中接收时间回调的方法是
Function myobject_onadd( v1, v2 )
MsgBox "add" & v1 & v2
End Function
Set Cnxn4 = WScript.CreateObject( "ATLCom.ATL3" , "myobject_")
页面中使用的方法
<HTML>
<BODY ONLOAD="test()" LANGUAGE="VBS">
<SCRIPT LANGUAGE="VBS">
Function tt_onadd( v1, v2 )
MsgBox "add" & v1 & v2
End Function
Function test()
tt.Add 1, 2
End Function
</SCRIPT>
<SPAN ID="mySpan">SPAN</SPAN>
<object classid="clsid:1C6B8199-F7EA-4D8B-9F56-7F80ABAB16D0" id="tt">
</object>
</BODY>
</HTML>
[解决办法]
1楼正解..
[解决办法]
[解决办法]
友情up
[解决办法]
Dim Controller, RemoteScriptSet Controller = WScript.CreateObject("WSHController")Set RemoteScript = Controller.CreateScript("test.js", "remoteserver")WScript.ConnectObject RemoteScript, "remote_"RemoteScript.ExecuteDo While RemoteScript.Status <> 2 WScript.Sleep 100LoopSub remote_Error Dim theError Set theError = RemoteScript.Error WScript.Echo "Error " & theError.Number & " - Line: " & theError.Line & ", Char: " & theError.Character & vbCrLf & "Description: " & theError.Description WScript.Quit -1End Sub