环境:winxp + vc2003
1.也算不上原创,大多是从msdn和书上来的,转载请保留作者:http://www.ctag.cn,
或http://blog.csdn.net/waterpub,而且很古老的日记了,翻出来贴在这里,
有用的着的就看看把,msn:jinglexy at yahoo.com.cn
2.创建一个activex项目,记下clsid号,Dependency查看依赖的库:msvcr71.dll, msvcp71.dll,
MFC71.dll
3.使用cab sdk打包:
CABARC.EXE n active5.CAB active5.inf active5.ocx
msvcp71.dll MFC71.dll msvcr71.dll
inf编写如下:(修改里面的控件名和clsid号)
; ========================= active5.inf
========================
; This .inf file will control the installation of
the MFC Spindial
; control. This control has been compiled with
Visual C++ version 4.2.
; The FileVersion tags in the dependent DLLs
section on this file
; reflect this requirement.
[version]
; version signature (same for both NT and Win95) do
not remove
signature='$CHICAGO___FCKpd___0quot;
AdvancedINF=2.0
[Add.Code]
active5.ocx=active5.ocx
; These are the necessary supporting DLLs for MFC
4.2 ActiveX Controls
mfc71.dll=mfc71.dll
msvcr71.dll=msvcr71.dll
msvcp71.dll=msvcp71.dll
; thiscab is a keyword which, in this case, means
that active5.ocx
; can be found in the same .cab file as this .inf
file
; file-win32-x86 is an x86 platform specific
identifier
; See the ActiveX SDK - ActiveX Controls - Internet
Component Download -
; Packaging component code for automatic download
[active5.ocx]
file-win32-x86=thiscab
; *** add your controls CLSID here ***
clsid={954C7F44-564F-4A19-8701-3C2A0327B6D0}
; Add your ocx's file version here.
FileVersion=1,0,0,1
RegisterServer=yes
; dependent DLLs
[MFC71.dll]
file-win32-x86=thiscab
RegisterServer=no
DestDir=11
FileVersion=7,10,3077,0
[msvcr71.dll]
file-win32-x86=thiscab
RegisterServer=no
DestDir=11
FileVersion=7,10,3052,4
[msvcp71.dll]
file-win32-x86=thiscab
RegisterServer=no
DestDir=11
FileVersion=7,10,3077,0
; ====================== end of spindial.inf
=====================
4.生成spc证书:
makecert /sv 'key.pvk' /n 'CN=hojydotcom' VicAli.cer
cert2spc VicAli.cer VicAli.spc
5.对cab文件签名,运行vs2003的signcode.exe程序,选择cab文件,spc及pvk证书,
密钥使用md5算法。
6.web调用方式:
<OBJECT id='lyz_fax' codeBase='active5.cab'
height='100'
width='100'
classid='clsid:954C7F44-564F-4A19-8701-3C2A0327B6D0'
VIEWASTEXT>
</OBJECT>
当clsid不存在时会下载activex控件并安装
7.web显示,设置安全级别为低
8.以上测试通过,工具或配置文件的编写参考msdn
9.到微软处购买证书(也可能是中国的一个部门,具体情况不太清楚了),当时的价格是
2500人民币,现在不知道涨了没有^_^,网页上的控件满天飞,还好我已不用windows了~
2006.3.30