总结:
1.查找atl 注册信息:regsvr32 FirstAtl.dll 后,打开注册表,ctrl+F 后输入 FirstAtl.dll 开始搜索信息,直到出现下图
其中ProgID就是c++需要的信息
{A3bbxxxx}是html需要的信息
2.c++快速调用
#include "atlcomcli.h"
#import "D:\\workDocument\\Interface\\VS\\debug\\FirstAtl.dll" no_namespace
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
CLSID clsid;
CLSIDFromProgID(OLESTR("FirstClass.math.1"), &clsid);
CComPtr<IFirstClass> pFirstClass;//智能指针
pFirstClass.CoCreateInstance(clsid);
long ret = pFirstClass->Add(1, 2);
printf("%d\n", ret);
pFirstClass.Release();
CoUninitialize();
getchar();
return 0;
}
3.html快速调用
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script type="text/javascript">
function TestAtl(){
alert("a");
AtlDlls.Test();
var rst = AtlDlls.GetStatu();
alert(rst);
}
</script>
<title> 简单的OCX控件调用</title>
</head>
<body>
<object id = "AtlDlls" classid="clsid:a3bb4158-43D4-4A13-B1AD-6C8A987F4F39"> </object>
说明:*先注册控件:regsev32 控件路径
*classid="clsid:{a3bb4158-43D4-4A13-B1AD-6C8A987F4F39}" 为 控件clsid 在注册表中搜索"OCX_img.ocx"得到(有版本信息的那个)
<input value="Click" type="button" οnclick="TestAtl()"></input>
</body>
</html>