通过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…

改进的for循环

改进的for循环 声明局部循环变量 SystemVerilog简化了声明用于for循环的局部变量的方法。SystemVerilog可以在for循环内部声明循环变量。这样就不需要在模块级定义多个变量&#xff0c;也不用在命名的begin…end块中定义局部变量了。 module chip(...);//SystemVerilog风格的…

程序员们请别做下一个小贝

据网友提供的《蜗居》第24集3:30秒截图&#xff0c;有理由相信小贝是搞 C 的 那本书是《大规模C程序设计》 -- 历史上一定有那么一些人&#xff0c;没有名&#xff0c;没有钱&#xff0c;只是和爱人一起过完了一生。他们不用思念&#xff0c;不用写情话。他们的情话&#xff0c…

底部检测的do...while循环

底部检测的do…while循环 1、while循环可能从未执行 while循环有可能根本没有执行过。当执行流首次执行到循环的开头&#xff0c;控制值就为假的时候就会发生这种情况。 为了保证循环的每个输出都与循环的输入变量保持一致&#xff0c;使用这种在开头检测的while循环需要在循环…

模拟集成电路的经典教材

1.《Analysis and design of analog integrated circuits》, P.R. Gray, P.J. Hurst, Lewis and R.G.Meyer. 4TH. 这是模拟设计的最经典的教材。以前的版本主要是双极型晶体管设计&#xff0c;第4版增加了许多CMOS的内容。这本书推导分析非常详细&#xff0c;但对新手也许内容太…

[转]毕业5年决定你的命运 --------值得所有不甘平庸的人看看

正如"打工皇帝"唐骏说&#xff1a;"我觉得有两种人不要跟别人争利益和价值回报。第一种人就是刚刚进入企业的人&#xff0c;头5年千万不要说你能不能多给我一点儿工资&#xff0c;最重要的是能在企业里学到什么&#xff0c;对发展是不是有利……" 人…

改进的块名

改进的块名 代码中可包括多个嵌套begin…end块 命名的end可以和命名的begin配对 如果想在一个块的结尾指明它的名称&#xff0c;可以在关键字end后面加上:<名称>。在冒号的前后允许有空格&#xff0c;但不是必须的。 begin:<块名> ... end:<块名>这个跟着e…

verilog小结

1B4AAP346HJXSA9EWKU942M82是看一份资料小结的&#xff0c;图传不上来&#xff0c;以后能有个人空间了再传吧&#xff0c;&#xff08;北航夏宇闻的书不错&#xff09;。一&#xff1a;基本Verilog中的变量有线网类型和寄存器类型。线网型变量综合成wire&#xff0c;而寄存器可…

google G1,G2,G3比较(YY)

其实G1,G2,G3的主要不同点有以下几个&#xff1a; 1、CPUG1,G2都是Qualcomm MSM7201A 528 MHzG3是Qualcomm MSM7200A 528 MHz 应该说7201A出的时间比7200要晚一些&#xff0c;主频一样&#xff0c;可是功能上略低于7200&#xff08;执行效率是一样的&#xff09;根…

天才静之

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

改进的case语句

改进的case语句 SystemVerilog为case、casex和casez的判断提供了专门的unique和priority修饰符。这些修饰需放在关键字case、casex和casez前面。 unique case(<case_expression>)...//条件选项 endcasepriority case(<case_expression>)...//条件选项 endcase1、…

verilog经验谈

规范很重要工作过的朋友肯定知道&#xff0c;公司里是很强调规范的&#xff0c;特别是对于大的设计&#xff08;无论软件还是硬件&#xff09;&#xff0c;不按照规范走几乎是不可实现的。逻辑设计也是这样&#xff1a;如果不按规范做的话&#xff0c;过一个月后调试时发现有错…

priority case语句

priority case语句 一个priority case可能具有多个条件选项匹配 priority case语句指定&#xff1a; 至少有一个条件选项的值与条件表达式匹配如果有多个条件选项的值与条件表达式匹配&#xff0c;必须执行第一个匹配分支 修饰符priority表示设计者认为两个或多个条件选择表…

Windows Mobile logo测试介绍

首先声明本文转自&#xff1a;http://softtest.chinaitlab.com/sji/744369.html 一、Windows Mobile简介 Windows Mobile是微软主要针对手机市场而推出的一种操作系统&#xff0c;改系统和Nokia Sybian系统一样把手机推向了智能化。丰富的功能以及强大的品牌优势让这一系统逐渐…

Scroll Dialog

类似CScrollView的CDialog类 http://download.csdn.net/detail/hemmingway/7119551

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

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

改进的if...else判断语句

改进的if…else判断语句 SystemVerilog的判断修饰符unique和priority可以和if…else一起使用。使用这些修饰符不仅可以减少此类判断语句的不确定性&#xff0c;还可以在建模早期发现潜在的设计错误。 1、unique if…else判断语句 unique if…else可以并行求值 修饰符unique表示…

FPGA的IP核

http://blog.sina.com.cn/s/blog_5f6fcfce01012w4g.html IP核概述 利用IP核设计 电子系统 &#xff0c;引用方便&#xff0c;修改基本元件的功能容易。具有复杂功能和商业价值的IP核一般具有知识产权&#xff0c;尽管IP核的市场活动还不规范&#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;迅…