1. 第一部分:Sample Code

这部分转自:http://blog.csdn.net/hhygcy/archive/2009/05/04/4147870.aspx

最近这个东西很多被问及,软件动态升级的时候可能可以用到,在这里做一下记录。

就知道的方法有2个, 一个是通过ShellExecuteEx直接运行对应的CAB文件。一个是调用CreateProcess用wceload来调用这个CAB。 两个方法都可以,下面是写的测试程序中的代码:

view plaincopy to clipboardprint?
case ID_HELP_INSTALL1:  
    {  
        // Specify an action for the application to perform, flags and other parameters   
        SHELLEXECUTEINFO info;  
        info.cbSize = sizeof(info);  
        info.fMask = SEE_MASK_FLAG_NO_UI;  
        info.hwnd = NULL;   
        info.lpVerb = _T("open");  
        info.lpFile = _T("//Program Files//RunCAB//SampleCAB1.CAB");  
        info.lpParameters = _T(""); info.lpDirectory = _T("");  
        info.nShow = SW_SHOW;  
        info.hInstApp = g_hInst;  
        // Call to perform an action  
        ShellExecuteEx(&info);  
        break;  
    }  
case ID_HELP_INSTALL2:  
    {     
        LPTSTR szCmdline = _tcsdup(  
            TEXT("/"//Program Files//RunCAB//SampleCAB2.CAB/""));  
        CreateProcess(_T("wceload.exe"),szCmdline,NULL,NULL,FALSE,INHERIT_CALLER_PRIORITY,NULL,NULL,NULL,NULL);  
        break;  
    } 
    case ID_HELP_INSTALL1:
     {
      // Specify an action for the application to perform, flags and other parameters
      SHELLEXECUTEINFO info;
      info.cbSize = sizeof(info);
      info.fMask = SEE_MASK_FLAG_NO_UI;
      info.hwnd = NULL;
      info.lpVerb = _T("open");
      info.lpFile = _T("//Program Files//RunCAB//SampleCAB1.CAB");
      info.lpParameters = _T(""); info.lpDirectory = _T("");
      info.nShow = SW_SHOW;
      info.hInstApp = g_hInst;
      // Call to perform an action
      ShellExecuteEx(&info);
      break;
     }
    case ID_HELP_INSTALL2:
     { 
      LPTSTR szCmdline = _tcsdup(
       TEXT("/"//Program Files//RunCAB//SampleCAB2.CAB/""));
      CreateProcess(_T("wceload.exe"),szCmdline,NULL,NULL,FALSE,INHERIT_CALLER_PRIORITY,NULL,NULL,NULL,NULL);
      break;
     }

这个测试程序用不同的menuitem做了不同的尝试, 上述的两个实现都是可以工作的。需要注意的事情是上面的CreateProcess需要把含有空格路径参数用引号括起来。

2. 详细的相关资料

http://msdn.microsoft.com/en-us/library/bb158700.aspx

The Wceload tool (Wceload.exe), which is an XML-based CAB installer application, runs on your target device. You typically use this tool to install a .cab or .cpf file to a location that you select on the target device. Most .cab files are configured to enable the user to select the destination volume where the .cab file will be installed, either /Device or /Storage Card. However, you can choose to suppress the destination volume selection prompt and install the .cab file to a default location, specified in the .inf file used to create the .cab file.

Typically, you do not directly call Wceload. Instead, Wceload is called programmatically by other programs to install .cab files. For example, if you use File Explorer to view and open a .cab file, Shell automatically invokes Wceload for installation of the .cab file.

For information about creating a .cab file, see CAB Files for Delivering Windows Mobile Applications.

Wceload implements security mechanisms and performs installation tasks for .cab and .cpf files on Windows Mobile powered devices.

Wceload installs .cab and .cpf files using the following process:

  1. Wceload receives a .cab or .cpf file through one of the delivery mechanisms. While ActiveSync can send multiple .cab or .cpf files in one batch, each file is processed in turn.
  2. If the file is signed, Wceload attempts to verify the included certificate against certificates placed in the SPC Store.
  3. If the .cab file is unsigned, the security role to be used for the installation is determined by the SECPOLICY_UNSIGNEDCABS and SECPOLICY_UNSIGNEDPROMPT security policies.
  4. After the certificate verification process occurs, Wceload opens the .cab file for allowed installations and extracts the included _setup.xml file, which is passed to the Configuration Manager for processing.

For information about creating cab files, see CAB Wizard.

 Syntax
Copy Code
wceload.exe [ /delete <number> | /noui ] [ /confignotify | /nodelete | /safe | /silent | /verifyconfig] <cab file location>

 Parameters
/confignotify

Generates a configuration result notification that is placed in the Text Message store on the device.

/nodelete

Specifies that the .cab file is not removed after installation.

Note:
If you do not specify /nodelete or /delete 0 when running Wceload, the .cab file is deleted even if the installation is not successful.
/delete <number>

Specifies how Wceload removes the cab file after installation.

Note:
If you do not specify /nodelete or /delete 0 when running Wceload, the .cab file is deleted even if the installation is not successful.
Value Description

0

Does not remove the .cab file after the contents are installed.

1

Removes the .cab file after the contents are installed.

This is the default value.

/noui

Specifies that the user will not be prompted for any input during the installation. By default, prompts are answered with 'Yes'.

However, if the .cab file is unsigned, any security-related prompts will default to 'No' for security reasons, and the installation might fail.

This is the same as /silent for legacy compatibility reasons.

/safe

Specifies that the .cab file cannot contain executable files. Also; if the .cab file is unsigned; it can only use restricted permissions, ensuring that it will not be able to write to protected files and registry keys.

/silent

Suppresses dialog boxes during the installation, and all Yes/No prompts default to 'Yes', unless the .cab file is not signed. However, if the .cab file is unsigned, any security-related prompts will default to 'No' for security reasons, and the installation might fail.

This is the same as /noui for legacy compatibility reasons.

/verifyconfig

Specifies that the Wceload tool must verify whether the file passed in is a .cpf file. If the file is not a .cpf file, the installation fails.

cab file location

Specifies the location of the cab file to install or remove.

 Remarks

In Windows Mobile Version 5.0 and later, when using Wceload.exe to reinstall a .cab file, Wceload.exe uninstalls the previously installed version of the .cab file before installing the new version. During the uninstallation portion of this process, Wceload.exe closes any currently running executables that were installed on the target device using a .cab file, based on their filename. Wceload.exe also closes any executables that are the target of a file operation, such as a move or a copy. To close an executable, Wceload.exe sends WM_CLOSE to all top-level windows owned by the process. If the process does not exit in a timely manner after receiving the WM_CLOSE message, then Wceload.exe forcibly closes it by calling TerminateProcess. Wceload.exe does not attempt to close executables that are shipped in the run-time image on the target device.

If the .cab file is not signed, and you specify the /silent or /noui options when calling wceload, wceload may ignore these options.

The following code example shows how to call Wceload.exe to install a .cab file called MyCabFile.cab, while suppressing all dialog boxes during the installation. After installation, the .cab file is specifically not removed.

 Example
wceload /nodelete /silent "/Temp/MyCabFile.cab"

通过ap运行cab安装程序的方法及Sample Code相关推荐

  1. 一键安装,双击运行——Java安装程序制作

    如果您喜欢这些文章,欢迎点击此处订阅本Blog <script type="text/javascript"></script> <script sr ...

  2. Kali下卸载程序和安装程序的方法

    Kali下卸载程序的方法 一.kali中主要为2种卸载方法: 1.apt 2.dpkg 使用apt的方式有: apt-get remove 软件名apt-get remove --purge 软件名( ...

  3. 系统无法在此计算机硬件上运行,Windows安装程序无法将配置未在此计算机的硬件上运行的解决方案-太平洋电脑网...

    "Windows安装程序无法将Windows配置未在此计算机的硬件上运行",在PE下重装Win7 64位系统的时候出现这个提示是不是让遇到此问题的你十分崩溃? 经过在多台机N次的重 ...

  4. firefox linux脚本启动,在Linux终端中使用后台运行模式启动程序的方法

    这是一个篇幅不长但是十分有用的教程,可以帮助你在终端启动一个Linux应用程序,并且使终端窗口不会丢失焦点. 我们有很多可以在Linux系统中打开一个终端窗口的方法,这取决于你的选择以及你的桌面环境. ...

  5. 计算机无法继续安装程序,解决方法:如果计算机继续无法安装图形驱动程序,该怎么办...

    一些网民经常说,在计算机上重新安装系统后,图形卡驱动程序的安装已显示失败.他们不知道如何解决问题.今天,我将为您介绍计算机无法安装显卡驱动程序的解决方案.希望对您有所帮助.大家. 计算机无法继续安装显 ...

  6. linux中常用安装程序的方法,Linux下常见的软件安装方式

    一.Linux源码安装 1.解压源码包文件 源码包通常会使用tar工具归档然后使用gunzip或bzip2进行压缩,后缀格式会分别为.tar.gz与.tar.bz2,分别的解压方式: #tar -zx ...

  7. msu文件无法运行_安装程序遇到报错?无法验证发布者?无法使用脚本直接调用?...

    你是不是在运行的某个程序的时候经常遇到这个问题?是不是很烦?发现有好多文件都是这个情况? 单个文件可以修改文件属性,选择解除锁定就可以了: 那么问题来了,很多很多很多很多个文件点起来不要命了么? 不要 ...

  8. ubuntu下firefox中,直接在网页上安装程序的方法

    我不知道别人是怎么做的,反正这个问题恶心死了. ubuntu下安装软件,一般都是gogole到一个页面,然后上面告诉你把下面的代码输入到ternimal. sudo apt-add-repositor ...

  9. linux xmind无法运行,linux安装xmind的方法步骤

    1.下载xmind 百度,官网下载xmind linux版本 或本地下载地址https://www.jb51.net/softs/587908.html 2.解压到安装目录 我的安装目录是/opt/x ...

最新文章

  1. 某头条程序员吐槽:前同事银行流水造假,背调也是找同事编的!工资翻了300%!自己老实巴交提供真实银行流水,却惨遭压薪!...
  2. 前端学PHP之文件操作
  3. R语言包安装方法,及优质包推荐
  4. 步骤2 - websocket服务器转发请求给orchestra
  5. 垃圾,还用汇编写单片机程序?
  6. 全字符微信名 php,PHP方法处理微信昵称特殊符号过滤
  7. (需求实战_进阶_04)SSM集成RabbitMQ 通配符模式 关键代码讲解、开发、测试
  8. html网页字段序号的样式,[网页设计]局部自定义li序号CSS样式的方法
  9. TOM邮箱|163邮箱如何注册?怎么登陆?
  10. 程序员,你以为你很优秀,但却面试屡屡失败?
  11. java解析micaps_9210的Micaps第13类卫星云图数据
  12. 使用Via浏览器+ADM下载器突破百度网盘下载限速
  13. unity修改默认字体
  14. 海水淡化三十年打磨一把反渗透膜“利剑”
  15. unity火焰粒子效果
  16. 隔离电源与非隔离电源的选择及优缺点分析
  17. 现在Python就业很难吗?百万程序员都在关心的问题
  18. Java SSH框架学习(入门)
  19. 论文阅读: Towards Automatic Face-to-Face Translation
  20. 模拟射击训练系统需要准备多大的场地

热门文章

  1. 焦作一中高考成绩查询2021,2021年焦作高中学校排名及录取分数线排名
  2. html怎么使背景图片充屏,css如何使div背景图片填充
  3. yum错误---Running Transaction
  4. linux 内核 工作队列,Linux内核新旧工作队列机制的剖析和比较
  5. 写给萌新,聊聊你初入职场的那些疑惑~
  6. 没有run窗口_学会了面向对象,还怕没有对象?
  7. mysql union后面查不出_mysql – 多个UNION查询不起作用
  8. python探测端口_python检测远程服务器tcp端口的方法
  9. 废旧光盘手工小制作_废旧光盘没有用,只能扔?这些光盘改造的小手工就很惊艳,附教程...
  10. Java学习笔记_方法