VB-ocx应用于Web

以下是html调用示例,ClassID为用vb自带的打包工具,打包获得的。

<html>

<br>

<OBJECT

CLASS

CODEBASE="Cti_Client1100504.CAB#version=1,0,0,8">

</OBJECT>

<br>

<a href="javascript:m_坐席登陆('192.168.1.106','5010','agent4','000000')" >m_坐席登陆</a>执行ocx中的方法

<br>

<a href="javascript:m_关闭软电话()" >m_关闭软电话</a>

<br>

<a href="javascript:m_显示电话号码('1112222')" >m_显示电话号码</a>

<br>

<script type="text/javascript">

function m_坐席登陆(str服务器地址,str服务器端口,str坐席员名,str密码)

{ CtiClient.m_坐席登陆(str服务器地址,str服务器端口,str坐席员名,str密码); }ocx中的方法

function m_关闭软电话()

{ CtiClient.m_关闭软电话(); }

function m_显示电话号码(str)

{ CtiClient.m_显示电话号码(str); }

</script>

<SCRIPT type="text/javascript" FOR="CtiClient" EVENT="e通讯错误(strMsg)" >ocx中的事件 触发javascript

m_ShowMsg(strMsg);

</SCRIPT>

<SCRIPT type="text/javascript" FOR="CtiClient" EVENT="登陆失败()" >

m_LoginNo();

</SCRIPT>

<script type="text/javascript">

function m_ShowMsg(strMsg)

{

alert(strMsg);

}

function m_LoginNo()

{

alert('登陆失败');

}

</script>

</html>

ocx本地化配置

1.创建一个setup.reg文件,内容如下:

注:":Range"="192.168.1.222" 为服务器IP地址

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range9]

":Range"="192.168.1.222"

"http"=dword:00000002

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2]

"1004"=dword:00000000

"1201"=dword:00000000

"CurrentLevel"=dword:00000000

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\New Windows]

"PopupMgr"="yes"

2.创建一个*.bat文件,内容如下:

%windir%\system32 为系统system32路径

Cti_Client1100504.ocx为ocx文件名

@echo off

taskkill /f /im iexplore.exe

copy Cti_Client1100504.ocx %windir%\system32\Cti_Client1100504.ocx

regsvr32 %windir%\system32\Cti_Client1100504.ocx "-u" "-s"

regsvr32 %windir%\system32\Cti_Client1100504.ocx

regsvr32 %windir%\system32\Cti_Client1100504.ocx "-u" "-s"

regsvr32 %windir%\system32\Cti_Client1100504.ocx

setup.reg

exit

将这两个文件放在同一目录下,执行bat文件。