最近做directshow插件,用于网页,参照别人的cab做法,自己做了下,ocx文件需要有版本信息。
1.编写inf文件,例如your.inf
signature="$CHINA$"
AdvancedINF=2.0
[DefaultInstall]
AddReg = AddReg
[Add.Code]
your.ocx=your.ocx
;Start of ffdshow
ff_kernelDeint.dll=ff_kernelDeint.dll
ff_liba52.dll=ff_liba52.dll
msvcp71.dll=msvcp71.dll
msvcr71.dll=msvcr71.dll
TomsMoComp_ff.dll=TomsMoComp_ff.dll
ff_vfw.dll.manifest=ff_vfw.dll.manifest
ffdshow.ax.manifest=ffdshow.ax.manifest
ffdshow.ax=ffdshow.ax
;End of ffdshow
mfc42.dll=mfc42.dll
msvcrt.dll=msvcrt.dll
olepro32.dll=olepro32.dll
[your.ocx]
FILE=thiscab
CLSID={6F5A0B29-5C26-49A1-9462-4C9910F085F3}
FileVersion=1,1,7,0
RegisterServer=yes
;Start of ffdshow
[ff_kernelDeint.dll]
FILE=thiscab
[ff_liba52.dll]
FILE=thiscab
[msvcp71.dll]
FileVersion=7,10,3077,0
FILE=thiscab
[msvcr71.dll]
FileVersion=7,10,3052,4
FILE=thiscab
[TomsMoComp_ff.dll]
FILE=thiscab
[ffdshow.ax.manifest]
FILE=thiscab
[ff_vfw.dll.manifest]
FILE=thiscab
[ffdshow.ax]
FILE=thiscab
CLSID={04FE9017-F873-410E-871E-AB91661A4EF7}
FileVersion=1,0,2,1997
RegisterServer=yes
[mfc42.dll]
FileVersion=6,2,4131,0
hook=mfc42installer
[msvcrt.dll]
FileVersion=7,0,2600,2180
hook=mfc42installer
[olepro32.dll]
FileVersion=5,1,2600,2180
hook=mfc42installer
[mfc42installer]
file-win32-x86=VALUE=http://activex.microsoft.com/controls/vc/mfc42.cab
run=%EXTRACT_DIR%/mfc42.exe
2.编写压缩cab文件bat,比如cabcreate.bat
REM #################### Begin of generate Your.CAB ########################
SET Files=your.ocx
SET Files=%Files% ../ffdshow/*.dll
SET Files=%Files% ../ffdshow/*.manifest
SET Files=%Files% ../ffdshow/*.ax
SET Files=%Files% ./your.inf
@del your.cab
CABARC -s 6144 n your.cab %Files%
3.编写制作签名cab文件bat,比如cabsign.bat
@echo off
SET PATH=%PATH%;D:/Program Files/Microsoft Platform SDK for Windows XP SP2/Bin;E:/Source/makeCAB
set CABFile=your.cab
set PVKFile=YourControl.pvk
set CERFile=YourControl.cer
set SPCFile=YourControl.spc
set PFXFile=YourControl.pfx
set PASS=yourpass
@del %PVKFile%
@del %CERFile%
@del %SPCFile%
@del %PFXFile%
IF NOT EXIST %PVKFile% makecert -sv "%PVKFile%" -n "CN=Your Company,E=your site,O=yourname" -b 01/01/2000 -e 01/01/2099 %CERFile%
IF NOT EXIST %SPCFile% cert2spc %CERFile% %SPCFile%
IF NOT EXIST %PFXFile% pvk2pfx.exe -pvk %PVKFile% -pi %PASS% -spc %SPCFile% -pfx %PFXFile% -f
rem signcode.exe /spc YourControl.spc /v YourControl.pvk YourControl.cab
rem signcode.exe
signtool sign /f %PFXFile% /p %PASS% /v /d "yourname" "%CABFile%"
REM signtool.exe verify /v /a "%CABFile%"