为网页控件制作cab包及查控件classid的方法

来源:互联网 发布:淘宝特卖天天特价 编辑:程序博客网 时间:2024/05/17 20:38
MakeCAB是微软提供的制作CAB的文件,详细的MakeCAB介绍请参考微软MSDN。
正好这几天做的一个WEB ActiveX SIP Phone需要打包成.CAB文件,于是稍微研究了一下MakeCAB的用法。
直接运行MakeCAB,系统给出命令用法如下:

C:Documents and SettingsSunDesktopwebsipp>makecab
Microsoft (R) Cabinet Maker - Version 5.1.2600.2180
Copyright (c) Microsoft Corporation. All rights reserved..
MAKECAB [/V[n]] [/D var=value ...] [/L dir] source [destination]
MAKECAB [/V[n]] [/D var=value ...] /F directive_file [...]
source         File to compress.
destination     File name to give compressed file. Ifomitted, the
                        last character of the source file name is replaced
                      with an underscore (_) and used as the destination.
/F directives A file with MakeCAB directives (may berepeated).
/D var=value   Defines variable with specified value.
/L dir         Location to placedestination (default is current directory).
/V[n]           Verbositylevel (1..3).

如果目录里面有多个文件,那么就需要编写一个文件列表文件,用来告诉MakeCAB,有多少文件需要打包。
简单的编写了一个list.txt文件,里面仅仅包含2行。一个是libactivex.inf,一个libactivex.dll
然后执行:

makecab /F list.txt /D compressiontype=lzx /Dcompressionmemory=21 /V

系统将显示压缩过程和压缩结果,如下:

Microsoft (R) Cabinet Maker - Version 5.1.2600.2180
Copyright (c) Microsoft Corporation. All rights reserved..
287,395 bytes in 2 files
Totalfiles:              2
Bytes before:       287,395
Bytes after:         162,170
After/Before:            56.43% compression
Time:                    0.74 seconds ( 0 hr 0 min 0.74 sec)
Throughput:            378.76 Kb/second

压缩之后,目录下将生成一个目录,将目录里面的文件改名成libactivex.cab(可以是你需要的文件名)就OK了。

然后就可以放到WEB服务器的目录下,IE打开的时候就会提示下载了。


2.查控件classid:

在注册表中,查找  XYZ.ocx,就可以看到它的classid


Demo:

list.txt  1.jpg   3.jpg 在同一文件夹test下,在list.txt中:

1.jpg
3.jpg


在cmd中,先到test文件夹下,然后执行:makecab /F G:\test\list.txt /D compressiontype=lzx /D compressionmemory=21 /V

则在该文件夹下,会生成相应的文件