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

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.

Copy Code

wceload.exe [ /delete <number> | /noui ] [ /confignotify | /nodelete | /safe | /silent | /verifyconfig] <cab file location>
/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.

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.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/243256.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

MFC透明桌面flash金鱼

代码&#xff1a; http://download.csdn.net/detail/hemmingway/6823935 使用方法&#xff1a; //0,添加left.png&#xff0c;right.png资源文件 //1, 头文件定义变量 GoldFish pet; //2, 在CPP文件创建 // Create a goldfishif (!pet.Create(NULL, NULL, WS_CHILD | WS_VISIB…

天才静之

木心说&#xff1a;“最高一层天才&#xff0c;是早熟而晚成的。”我一直认为静之就是一个天才。天才不同于才子&#xff0c;才子早熟&#xff0c;但往往短命&#xff0c;而静之却常胜不衰&#xff0c;愈“老”弥坚。 从诗歌、散文到小说&#xff0c;从电视剧、电影再到话剧、歌…

“象征界”的奇观:刘天怜花鸟工笔作品印象

有人说&#xff1a;“创新”是西洋画的基调&#xff0c;中国画的焦点是“承传”。就是说&#xff0c;西画必须花样翻新&#xff0c;挑战前人&#xff0c;甚至要推倒重来&#xff0c;唯此才可能在艺术史上占有一席之地&#xff1b;中国画强调以古人为师&#xff0c;重视师徒之间…

亚马逊正式发布关系型数据库Amazon Aurora

在去年的AWS re:Invent大会上&#xff0c;亚马逊宣布了Amazon Aurora。Aurora是一个关系型数据库&#xff0c;可以跨3个可用区域复制6份数据&#xff0c;其设计目标是提供高性能和高可用性&#xff08;99.99%&#xff09;&#xff0c;并且存储可以轻松高效地扩展到64TB。近日&a…

刘小东的“空城记”

刘小东的“空城记” 。从“三峡移民”到“金城小子”&#xff0c;从“温床”&#xff0c;再到"新疆和田 ”,今天&#xff0c;刘小东又把“鄂尔多斯” 纳入自己介入现实的创作计划。鄂尔多斯&#xff0c;一个中国曾经最贫瘠的所在&#xff0c;因为矿产开发&#xff0c;迅…

聆听南音

北京。半木空间。聆听南音古曲。 南音亦称弦管、南乐。起于晋唐&#xff0c;盛于南宋&#xff0c;至今流传于泉州闽南地区。被誉为“中国音乐史上的活化石” 。今晚&#xff0c;南音传人蔡雅艺率三位南音大师现场演出、宣讲并与"半木"品牌创始人吕永中先生对话交流…

远程管理 KVM 虚机 - 每天5分钟玩转 OpenStack(5)

上一节我们通过 virt-manager 在本地主机上创建并管理 KVM 虚机。其实 virt-manager 也可以管理其他宿主机上的虚机。只需要简单的将宿主机添加进来 填入宿主机的相关信息&#xff0c;确定即可。 接下来&#xff0c;我们就可以像管理本地虚机一样去管理远程宿主机上的虚机了。 …

KVM 存储虚拟化 - 每天5分钟玩转 OpenStack(7)

KVM 的存储虚拟化是通过存储池&#xff08;Storage Pool&#xff09;和卷&#xff08;Volume&#xff09;来管理的。 Storage Pool 是宿主机上可以看到的一片存储空间&#xff0c;可以是多种类型&#xff0c;后面会详细讨论。Volume 是在 Storage Pool 中划分出的一块空间&…

LVM 类型的 Storage Pool - 每天5分钟玩转 OpenStack(8)

LVM 类型的 Storage Pool 不仅一个文件可以分配给客户机作为虚拟磁盘&#xff0c;宿主机上 VG 中的 LV 也可以作为虚拟磁盘分配给虚拟机使用。 不过&#xff0c;LV 由于没有磁盘的 MBR 引导记录&#xff0c;不能作为虚拟机的启动盘&#xff0c;只能作为数据盘使用。 这种配置下…

UltraEdit中高亮显示verilog HDL关键词

UltraEdit是一款功能强大的文本编辑器&#xff0c;可以编辑文字、Hex、ASCII码&#xff0c;可以取代记事本&#xff0c;内建英文单字检查、C 及 VB 指令突显&#xff0c;可同时编辑多个文件&#xff0c;而且即使开启很大的文件速度也不会慢。是一个使用广泛的编辑器&#xff0c…

CCS的基本操作

CCS的基本操作 1、 创建新工程 方法一&#xff1a; 方法二&#xff1a; 进入工程界面后&#xff0c;第一步选择芯片型号&#xff0c;第二步选择仿真器&#xff0c;第三步编写工程名称&#xff0c;选择工程模板。最后点击finish 2、 编译 方法一&#xff1a; 方法二&…

KVM 网络虚拟化基础 - 每天5分钟玩转 OpenStack(9)

网络虚拟化是虚拟化技术中最复杂的部分&#xff0c;学习难度最大。 但因为网络是虚拟化中非常重要的资源&#xff0c;所以再硬的骨头也必须要把它啃下来。 为了让大家对虚拟化网络的复杂程度有一个直观的认识&#xff0c;请看下图 这是 OpenStack 官网上给出的计算节点&#…

云计算与 OpenStack - 每天5分钟玩转 OpenStack(14)

“云计算” 算是近年来最热的词了。现在 IT 行业见面不说这三个字您都不好意思跟人家打招呼。 对于云计算&#xff0c;学术界有各种定义&#xff0c;大家有兴趣可以百度一下。 CloudMan 这里主要想从技术的角度谈谈对云计算的理解。 基本概念 所有的新事物都不是突然冒出来的&a…

OpenStack 架构 - 每天5分钟玩转 OpenStack(15)

终于正式进入 OpenStack 部分了。 今天开始&#xff0c;CloudMan 将带着大家一步一步揭开 OpenStack 的神秘面纱。 OpenStack 已经走过了 6 个年头。 每半年会发布一个版本&#xff0c;版本以字母顺序命名。现在已经到第 12 个版本 Liberty&#xff08;字母 L&#xff09;。 Op…

部署 DevStack - 每天5分钟玩转 OpenStack(17)

本节按照以下步骤部署 DevStack 实验环境&#xff0c;包括控制节点和计算节点 创建虚拟机 按照物理资源需求创建 devstack-controller 和 devstak-compute 虚拟机 安装操作系统 安装 Ubuntu 14.04&#xff0c;并配置 eth0 的 IP devstack-controller 192.168.104.10 devstak-c…

理解 Keystone 核心概念 - 每天5分钟玩转 OpenStack(18)

作为 OpenStack 的基础支持服务&#xff0c;Keystone 做下面这几件事情&#xff1a; 管理用户及其权限维护 OpenStack Services 的 EndpointAuthentication&#xff08;认证&#xff09;和 Authorization&#xff08;鉴权&#xff09;学习 Keystone&#xff0c;得理解下面这些概…

C++11 Lambda函数(匿名函数)

C11引入了lambda表达式&#xff0c;使得程序员可以定义匿名函数&#xff0c;该函数是一次性执行的&#xff0c;既方便了编程&#xff0c;又能防止别人的访问。 Lambda表达式的语法通过下图来介绍&#xff1a; Lambda表达式的引入标志&#xff0c;在‘[]’里面可以填入‘’或‘&…

时序约束与分析

时序约束与分析 设计约束所处的环节:约束输入、分析实现结果、设计优化。 设计约束分类 物理约束I/O接口约束(例如引脚分配、电平标准设定等物理属性的约束)、布局约束、布线约束以及配置约束。 时序约束:设计FPGA内部的各种逻辑或走线的延时,反应系统的频率和速度的约束…

通过例子学习 Keystone - 每天5分钟玩转 OpenStack(19)

上一节介绍了 Keystone 的核心概念。本节我们通过“查询可用 image”这个实际操作让大家对这些概念建立更加感性的认识。 User admin 要查看 Project 中的 image 第 1 步 登录 当点击时&#xff0c;OpenStack 内部发生了哪些事情&#xff1f;请看下面 Token 中包含了 User 的 R…

从Linux到Meego

网上看到一个Intel的强写的一篇关于meego的文章&#xff0c;很是受用&#xff0c;一篇好的文章就好比一顿每餐&#xff0c;在这里与大家分享。 从2月份Meego发布后一直在学习&#xff0c;现在把一些学到的内容跟大家共享一下。 首先想说说Meego是什么&#xff0c;Meego首先是…