[转帖]如何禁止安装Cab包时选择安装在存储卡

大家都知道,当您在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将始终为空值,在代码里要相应调整。其实,既然已经强制安装了,那么路径实际上已经固定,也就可以用些常量来表示路径了。

 

本文来自CSDN博客,转载标明出处:http://blog.csdn.net/Handsomewang527/archive/2007/10/09/1816155.aspx

posted @ 2010-05-11 18:13  摇滚诗人  阅读(499)  评论(0)    收藏  举报