如何禁止安装Cab包时选择安装在存储卡

来源:互联网 发布:去马赛克软件安卓版 编辑:程序博客网 时间:2024/04/30 02:50

    大家都知道,当您在Windows Mobile机器上安装程序时,如果机器上装有存储卡,会弹出一个窗口让您选择安装路径,即本机或存储卡上。但是,有时候,可能由于我们应用的特殊性,并不希望用户将软件安装在存储卡上,那么该如何去做呢?

       其实,微软的SDK已经给出了答案,在“Adaptation Kit User 's Guide  > Utilities  > CAB Wizard  > Information File  > Device-Side Application Installation Options”中,微软写到:

       To disable user-selected installation volume prompting Do not specify an %installdir% variable in the [CEStrings] section of the .inf file. If this variable is not found, the device will not prompt the user. 

       我们通常在编写打Cab包的inf文件时,都会在[CEStrings] 下定义%InstallDir%,如:

       [CEStrings]

InstallDir  = %CE1%/%ProviderStr%/%AppName%

AppName     = "Test"

 

这时,当安装Cab包时,发现有InstallDir,机器又安装了存储卡时就会提示用户选择是否安装于存储卡,那么我们要做的就是不给InstallDir赋值,即删去上面那句,

[CEStrings]

AppName     = "Test"

 

这样即使机器上安装了存储卡,那么安装Cab包时也会直接安装于本机[DefaultInstall][DestinationDirs]配置的位置。

但是,这样做要特别注意的是,对于控制安装进程的Setup.dll的编写,在编写该DLL时,我们常常用到“LPCTSTR     pszInstallDir”这个参数,因为它标识了Cab包安装时软件实际安装的路径。即InstallDir指定的路径或者存储卡下InstallDir指定的路径,但是现在由于没有指定InstallDir,故pszInstallDir将始终为空值,在代码里要相应调整。其实,既然已经强制安装了,那么路径实际上已经固定,也就可以用些常量来表示路径了。

看技术看累的吧,快去我的非技术Blog--猫思猫想(http://hi.baidu.com/doglovecat)