Start with CreateProcess (\ Windows \ wceload.exe ........) to automatically install a cab package. Later I found that multiple cab packages need to be installed. However, the CreateProcess function must install the cab package only after the main function returns, you cannot install the second cab package.
Later, I checked on the Internet. There was an example in the mobile SDK, which was actually very simple. I only needed to create a new cab project, put an EXE and a DLL and the cab to be installed in your new cab package, and then modify the registry. It's easy to do. To understand it, you still have to pay for it...
Example in WINDOS mobile 6sdk (program files/Windows Mobile 6 SDK/samples/common/CPP/Win32/multicabinstall)
Multicab whitepaper.doc:
Install Multiple cab packages in a cab package (cab package chain)
Microsoft
Applicable:
Microsoft visualstudio 2005
Microsoft Windows Mobile 5.0 SDK for smartphone
Microsoft windowsmobile 5.0 SDK for Pocket PC
Microsoft. NET Compact Framework Version 2.0
Overview:Installing multiple cab packages (sometimes called cab chains) in a single cab package does not work except for Windows Mobile devices. This section describes the sample code for installing multiple cab packages and the process.
Introduction
This White Paper demonstrates how to install and deploy multiple cab packages through one cab package (that is, the continuous installation of multiple cab packages as we know. This description looks simple, but it does require some code and workload. However, do not be afraid. The White Paper provides an example to allow you to easily create your own continuous installed cab package using the least modified code.
How can this be used? A good example of continuous installation of the cab package is to deploy your application and Its. net2.0 platform to a Windows mobile5.0 device.
Procedure
Here, the key technical point we are interested in is the role of 'setup. dll 'After extracting the cab package. The wceload program is responsible for the decompression work. Here we create a new executable file called multicab.exe. First, let's discuss javaswceload.exe.
Wceload.exe in
Http://msdn.microsoft.com/library/default.asp? Url =/library/en-US/wcepbguide5/html/wce50lrfwceloadtool. asp here and other places that can be easily accessed are described. Its core function is to install or remove the cab package in your specified directory. If you do not specify a specific location, the cab package will be installed in the default location or removed from the default location. The default location is the ProgramFiles file directory on your target device.
Setup. dll exports the functions that wceload.exe calls when extracting a cab file. These library functions can be encoded at different stages during the installation of the cab package. In http://msdn.microsoft.com/library/default.asp? Url =/library/en-US/dv_evtuv/html/etgrfsetupdllfilesfordevices. asp at least one extended document can be seen here.
The exported function is:
Install_init
Install_exit
Uninstall_init
Uninstall_exit
These functions are called functions you think (for more details, refer to the msdn documentation ). The sample code of setup. dll will be applied in our mcsetup project. The DLL name is not necessarily setup. dll, but the name specified in the ubercab package. Here we create this DLL and name it mcsetup. dll.
As part of this article, multicab.exe is also an executable file to be created, and uninstall_exit will be referenced.
Here is a high-level summary of how these files Install Multiple cab packages consecutively from a cab package, Or uber cab, Package Multiple cab packages to be installed.
- The user's operations on uber cabpackets are implemented by shellusing wceload.exe to install the cab package to the device.
- Decompress uber cab and download its internal cab package to the device (but it does not decompress the content of the internal cab, this is the problem we are solving and we will create a registry to mark which cab packages have been installed)
- Wceload.exe calls the install_exit function of mcsetup. dll.
- Install_exit start multicab.exe to decompress Those cab packages
- Multicab.exe uses the registry key to enumerate all cab packages, decompress them, perform some simple operations, and then exit.
Next we will follow these steps. Here I will demonstrate how to perform this operation on the vs2005 official website. In addition, the vs steps for earlier versions are similar.
- Compile mcsetup. dll in the project
- Compile multicab.exe in the project
- Create an Uber cab package that contains multiple other cab packages to be installed (the specific creation process is as follows ):
- File-> new project ....
- Other project types-> setup and deployment-> smart device cab Project
- Place the cab package in the project, or right-click the project name to add the cab package, or use other known methods.
- For example, I have added simpleappcab1, 2, and 3 in the Uber cab package. netcfv2 cab (on my device. netcfv2 cab is at c: \ Program Files \ Microsoft Visual Studio 8 \ smartdevices \ SDK \ compactframework \ 2.0 \ 2.0 \ V2.0 \ WindowsCE \ wce500 \... -The following wce400 \... PATH is on the 2003 device)
- Upload multicab.exe (then add mcsetup. dll) in the Uber cabpack)
- Set necessary properties of Uber cab
- Open the Properties window or dialog box (if not found, select project-View-> Properties window)
- In the Properties window, set ce setup DLL to mcsetup. dll, and select Browse from the CE setup DLL entry... Double-click the Program Files folder and add a file... Introduce mcsetup. dll.
- Open the cab registry View
I. Right-click the project name and choose View> Registry)
- Add a key for the multicab.exe program to know the name of Uber cab. This path can be arbitrary. (You only need to specify the path required by the multicab.exe code to create a statement in the section displayed in hkcu(hkey_current_user ..
- Add the key value pointing to the cab package contained in Uber cab. These key values are consistent with the path they downloaded from Uber cab. This key value table is the one installed in the specified multicab.exe repository. In addition, the previous notebook can be any one that must be consistent with the multicab.exe code. The registry key value shown in the figure below indicates the four cab packages to be installed, which are all in order.
- Compile the Uber cab Project
This is the case. Deploy uber cab on a device or simulator and execute it. When it decompress itself, it will immediately decompress its internal cab package. Note that the cab package will be decompressed and installed according to the numerical order on the registry above. In addition, because the. netcfcab package needs to restart the device after installation, you must put it in the final installation. If you need to restart multiple cab after installation, the subsequent cab will not be installed. If you do not need to restart the cab after installation, you can add other cab packages, which will be decompressed and installed.
In this process, multicab.exe will delete the used registry key, but it will not delete itself, this is also for future expansion and for users to view.
How to reuse this example
Re-use the example cab Installation tool is meaningless. You only need to modify the code in mcsetup. cpp and multicab. cpp. here you want to point out the path of your desired registry.
See row 51 of mcsetup. cpp and row 124 in multicab. cpp, and replace "Software \ chainedcabsample" with appropriate values ":
Consttchar c_szappregpath [] = text ("Software \ chainedcabsample ")
You must also set the value of % yourpath % \ multicab \ installcabname in step # 4D to name your Uber cab name. Logically, this program assumes that uber cab installs multicab.exe to \ ProgramFiles \ % yourcabname % \ multicab.exe. (You can also see that "ubercab" is used as the name in the example)
In fact, you only need to specify the cab package to be continuously installed in the smart device project according to # 4E. Then, compile the modified setup. dll and multicab.exe according to the above.
It is meaningless to change the multicab.exe name or change the setting of some programs if the verification code is less than the verification code.
Understanding of code
Now I have a deep understanding of what multicab.exe and mcsetup. dll have done.
Mcsetup. dll
Code. Now, the following path is created for multicab.exeand then shellexecuteex multicab.exe is called (in mcsetup. cpp:
1. find the registry value of installcabname (see line 68 and74) in HKEY_CURRENT_USER \ Software \ Microsoft \ multicab (here, the name of the multicab.exe application set by c_szmulticabapp ). in this case, installcabname is "ubercab" used to set up the file path.
2. 83 lines of File Creation Path:
\ ProgramFiles \ ubercab \ multicab.exe
3. Call #2 (94 rows) shellexecuteex
Multicab.exe
Note: multicab.exe uses the Registry created by uber cab to enumerate all cab packages, decompress them, and perform some simple registry cleanup operations. These logics are in multicab. cpp.
1. waitonloader (row 38) is a helper used to wait until wceload.exe ends.
This is required because, before installing the next cab package, you must wait until the previous one is complete. Otherwise, the next cab package will fail to be installed.
2. hostexec (98 rows)
Is an auxiliary function used to extract multiple cab packages.
3. Select the path of your registry key on Line 1:
Const tchar c_szappregpath [] = text ("Software \ chainedcabsample ");
Const tchar c_szappname [] = text ("multicab ");
Const tcharc_szkeyvalue [] = text ("installcabname ");
4. hkey_users_root \ Software \ chainedcabsample \ multicab saves the sub-path of the cab list.
5. Using the registry value "" retrievedfrom step #4, built with the registry value hkey_users_root \ Software \ chainedcabsample \ ubercabis obtained from #4 by using ubercab.
The handle of this key is opened in row 179 and some internal cab packages are obtained through regqueryinfokey in row 181.
6. Use the handle obtained from #5. This loop starts from row 191 and enumerates the cab registry.
While (dwkey <= ckeyvalues)
7. Each cab package will be executed in 205 rows in a loop. waitonloader waits for the previous cab package to be installed before continuing to install the next cab package.
If (hostexec (szregkeyvalue, & hprocess ))
{
Waitonloader ();
}
8. After all the cab packages are installed, this program will perform some registry cleaning and exit operations.
As soon as I got it done, I wrote this translation in a hurry. It may be inappropriate to modify it later. I feel like there are several images that make it easy to install multiple cab packages. But I still need to look at the code for a deeper understanding.
Note that only a cab package is created here. This cab package is different from a common one and is directly installed. This can be used to install multiple cab packages in the cab package continuously.
However, we can simply load this cab package through wceload.exe to implement continuous multi-cab installation.