ocx

1,新建mfc activeX控件 ,全部默认

2,类视图 右键xxxlib下面的xxxevents 添加方法 返回类型选择void

参数选择LONG BSTR 选择添加


typedef int (_stdcall * GWQPlayVoice)(int iPortNo ,char *strVoice);//定义函数指针类型
void CActiveXCtrl::GWQ_PlayVoice(LONG iCom, LPCTSTR strVoice)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    HINSTANCE hInst;
    GWQPlayVoice App_GWQ_PlayVoice;
    int iRet = 0;

    hInst=LoadLibrary(_T("liboutclearsqb_anzhentong.dll"));//动态加载Dll
    App_GWQ_PlayVoice=(GWQPlayVoice)GetProcAddress(hInst,"GWQ_PlayVoice");//获取Dll的导出函数
    if(!App_GWQ_PlayVoice)
    {
     MessageBox(_T("获取Add函数地址失败!"));
    }

    iRet=App_GWQ_PlayVoice( iCom, (char *)strVoice);
    
    if (iRet==0)
    {
        MessageBox(_T("成功!"));
    }
    else
    {
        MessageBox(_T("失败!"));
    }
    // TODO: 在此添加调度处理程序代码
}

3,注册 regsvr32 ***.ocx

4,将dll放在windows下面

5,编写网页

<OBJECT ID="ActiveX" WIDTH="100" HEIGHT="50" CLASSID="CLSID:5ACEFCA5-7285-40E4-94A3-16E99E8CCFBF">

</OBJECT>

//响应OCX控件的TestEvent1事件

<script language="javascript"  for="ActiveX"  event="TestEvent1(nVar)">   

alert("Event_TestEvent1 Param_nVar is:" + String(nVar));   

</script>   

//调用OCX控件的showInput函数的javascript函数

<script language="javascript">

function Show(varStr)

{
alert("提示信息!21111");  
ActiveX.GWQ_PlayVoice(0,"中国人民解放军");
alert("提示信息!122222");  
}

</script>

//html代码

</br></br>

<a href="javascript:Show('大家好!')" >调用OCX的showInput方法</a>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值