<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="zh"> <head> <title>ActiveXFileReader</title> </head> <body> <input type="button" value="window.alert" onclick="WAlert();"/> <input type="button" value="activex.alert" onclick="AAlert();"/> <object Id="FileUpLoadControl" Name="FileUpLoadControl" width="1" height="1" style="display:none;" classid="clsid:7DDD6A0D-4F6E-46F4-ADE1-E994856FDE89"></object> <script type="text/javascript"> function Get(){return document.all.FileUpLoadControl;} function IsLoad(obj){var o=obj||Get(),f=0;try{f=o.Ver();}catch(e){}return !!f;} function Ver(obj){var o=obj||Get();return o.Ver();} </script> <script type="text/javascript"> var reader=Get(); if(!IsLoad(reader)){ alert("控件注册失败!"); } function WAlert(){alert("window.alert");} function AAlert(){reader.alert("activex.alert");} </script> </body> </html>
调用ActiveX的alert方法时老是报错“参数类型不匹配”。
BSTR、LPCTSTR、CHAR*、CHAR都试过了,都不行,string类型又不允许使用,怎么办?
现在我把C++代码改成了这样,还是不行...
void CActiveXFileReaderCtrl::alert(BSTR str) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); // TODO: 在此添加调度处理程序代码 LPCTSTR message = str; LPCTSTR title = ::SysAllocStringByteLen("来自ActiveX的消息",18); MessageBox(message,title,MB_OK); }