日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發布時間:2023/12/15 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 通过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:

  • 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.
  • If the file is signed, Wceload attempts to verify the included certificate against certificates placed in the SPC Store.
  • 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.
  • 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.

    ValueDescription

    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的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。