The custom cab file for the device.
Reference: http://msdn.microsoft.com/zh-cn/library/cc433706 (vs.71). aspx
Embedded Development on Windows MobileSoftwareIt is not about j2me, but also the program written in other languages. You can use cabwiz.exe to package and install the package. I recently developed a project to understand that it is not only small but also powerful. I just finished a j2-based project under HP 4700 PDA, used the IBM j9 virtual machine, and used the DB2 everyplace embedded database. Finally, cabwiz is used to package the entire software. Share your experience with you. I hope that this experience will help you with your convenience.
Keywords: cabwiz.exe, cab, j2s, Windows Mobile 2003, Windows CE,
Ii. Basic Process:
In fact, the process is very simple:
I. First, prepare your own programs and make installation plans, including the target paths and registration operations of these files.
2. Make a list of installation files in the key part of the package Installer. This is a file suffixed with. INF.
3. Run cabwiz.exe to generate the installation package file with the suffix ". Cab ".
The most important thing is how to write this. inf file. This is the topic of this article. Here is a complete example.
Iii. Fan Wen app. inf
[Version]
Signature = "$ Windows NT $"
Provider ="Xilin_am@163.com"
Cesignature = "$ Windows CE $"
[Cestrings]
CompanyName = "XXX company"
Appname = Mobile Data Center
Installdir = % CE2 %/bjtzst
[Cedevice]
[Defainstall install]
Copyfiles = files. Application, database, picture, urllink
Ceshortcuts = shortcuts
[Sourcedisksnames]
1 =, "TXT ",,.
2 =, "shortcut ",,.
3 =, "lib ",,.
4 =, "DB",./bjtzdb
5 =, "url ",,.
[Sourcedisksfiles]
Mobile Data Center (PDA). url = 5
Tz. Jar = 3
Stwater.gif = 1
Atz. lnk = 2
Db2e_lock = 4
Dsy_dateinfo = 4
Dsy_date_type = 4
......
......
Dsy_unit = 4
Isyncprefs = 4
[Destinationdirs]
Files. Application = 0, % installdir %
Shortcuts = 0, % installdir %
Database = 0 ,.
Picture = 0, % ce5 %/individual
Urllink = 0, % CE2 %/favorites
[Database]
Db2e_lock, 0x00000001
Dsy_dateinfo, 0x00000001
......
......
Dsy_unit, 0x00000001
Isyncprefs, 0x00000001
[Files. Application]
"Tz. Jar", 0x00000001
"Atz. lnk", 0x00000001
[Picture]
"Stwater.gif", 0x00000001
[Urllink]
"Mobile Data Center (PDA). url", 0x00000001
[Shortcuts]
% Appname %, 0, atz. lnk, % ce17 %
Iv. inf file Introduction
. The inf file is composed of a series of paragraph segments. The names of each segment are defined in square brackets ([]). The names are case insensitive, I believe you will not get a node name with more than 255 bytes, because it is not sufficient. Each segment describes the object's target address, shortcuts, registration settings, and other information, which will be written into the. cab file. It plays a role in installation. Although these segments can be randomly arranged, the installation process will only determine the order of the segments in the INF file according to the name of each segment, but it is best to follow the order of the example to improve readability.
1. built-in macro string
First, you should understand that the INF file contains several fixed macro strings which point to the fixed directory in the Windows Mobile System. Here the two % and intermediate words are regarded as macros. The directories they direct to are very intuitive and commonly used, which makes the subsequent configuration easy.
% CE1 % Program Files
% CE2 % WINDOWS
% Ce4 % Windows/startup
% Ce5 % My Documents ents
% Ce8 % Program Files/games
% Ce11 % Windows/Start Menu/programs
% Ce14 % Windows/Start Menu/programs/games
% Ce15 % Windows/Fonts
% Ce17 % Windows/Start Menu
2. Introduction to typical sections
The following table lists the typical sections in the Windows CE information (. inf) file of the device.
Each section contains specific items. Some of these items start with predefined keywords (such as appname) or instructions pointing to other sections. The following table lists the typical commands in the. inf file.
Add the. inf file section
For some sections (such as defaultinstall), you can create additional sections to list the files used in the installation process. However, the specified syntax must be used for these sections. For example, the copyfiles command in section defaultinstall points to multiple files. the writer naming section for application, database, picture, and urllink lists the target file names, source file names, and logos used during default installation.
[Defainstall install]
Copyfiles = files. Application, database, picture, urllink
[Files. Application]
"Tz. Jar", 0x00000001
"Atz. lnk", 0x00000001
......
5. Detailed description of typical section instances
1. Version
[Version] is required. You can specify the application creator and version.
[Version]
Signature = "$ Windows NT $"; required. Specifies the. inf file pairOperating SystemValid String
Provider ="Xilin_am@163.com"; Enter the author's name here
Cesignature = "$ Windows CE $"
Note that cesignature = "$ Windows CE $" cannot be changed.
2. cestrings
[Cestrings] required. It specifies the application name and the string replacement or string keyword of the default installation directory.
[Cestrings]
CompanyName = "XXX company"; note that if a string contains spaces and quotation marks
Appname = Mobile Data Center; Add ". If there is no such situation, the string can also be left blank "";
Installdir = % CE2 %/bjtzst; macro can also be referenced in the string
3. Strings
[Strings] optional. It is used to define one or more string keywords,
In fact, it is the place where you define your own macro strings. You can add them if they are used in the project.
4. cedevice
[Cedevice] optional. The platform that the application supports or does not support. Cedevice contains information such as Windows CE version number, processor type value, and unsupported platform name. If native components are used, a subset of each processor that is jointly supported by those components should be included so that only the CAB files generated for each processor can be installed on the device using the corresponding processor.
For example:
[Cedevice]
Unsupportedplatforms = "HPC"; you can find
List of processors supported by Windows CE and their type values
But I developedSoftware, This option does not have any function. Let's hand over all the annoying CPU types to the Java Virtual Machine. I have to concentrate on development! However, generating multiple installation packages for different CPU types in an INF file is an advanced topic in this topic.
5. defainstall install
[Defainstall install] required. Specify information about the default installation of the application. Only copyfiles and addreg are required. The optional ceshortcuts item points to a section commonly referred to as shortcuts and specifies a shortcut created on the device during default installation.
[Defainstall install]
Copyfiles = files. Application, database, picture, urllink
Ceshortcuts = shortcuts
Because there are many installation files, I have created many additional sections to make the installation process clearer. Files. application is used to install program files, database is used to install databases, picture is used to process additional images, and urllink adds a collection to the publisher.
Shortcuts is responsible for installing the default Program Shortcuts. Because I am working on the development of j2s, no addreg item is used.
6. Additional sections defined by copyfiles. Pay special attention to the syntax.
For example
[Files. Application]
"Tz. Jar", 0x00000001
"Atz. lnk", 0x00000001
Syntax: "target file name", "source file name", flag
If the source file name has the same name as the target file name, you can save the source file name. Note that the first two "," numbers must not be fewer,
The number of final flags is an important parameter, which can be expressed directly by numerical values.
7. destinationdirs
[Destinationdirs] required. Specify the name and path of the target directory on the disk,
[Destinationdirs]
Files. Application = 0, % installdir %
Shortcuts = 0, % installdir %
Database = 0 ,.
Picture = 0, % ce5 %/individual
Urllink = 0, % CE2 %/favorites
Syntax: append segment name = 0, "target directory"
As shown in the above example, if you want to put files in several different directories, you need to generate different copyfiles additional sections by directory. The additional section of copyfiles only specifies the file to be operated, but does not specify the directory. The operation of the specified directory is implemented in destinationdirs, which respectively specifies the directories for different additional sections of copyfiles.
8. sourcedisksnames
[Sourcedisksnames] required. Specifies the name and path of the source disk where the application resides. You can specify multiple source disks.
[Sourcedisksnames]
1 =, "TXT ",,.
2 =, "shortcut ",,.
3 =, "lib ",,.
4 =, "DB",./bjtzdb
5 =, "url ",,.
Syntax: Number =, "tag", path
The number starts from 1 as agreed. The label can describe the file type. To make it easier for me to install files in the current directory,./bjtzdb is a sub-directory in the current directory. You can also use the absolute path C:/MyApp/newfolder. Note the odd use of commas.
9. sourcedisksfiles
[Sourcedisksfiles] required. Specify the name and path of the application file on the source disk where the application resides. You can specify any number of items, each corresponding to a file on the source disk.
[Sourcedisksfiles]
Mobile Data Center (PDA). url = 5
Tz. Jar = 3
Stwater.gif = 1
Atz. lnk = 2
Db2e_lock = 4
Dsy_dateinfo = 4
Dsy_date_type = 4
Here, the source object target of each file to be installed must be expressed in a concise manner, and the source file directory defined in the sourcedisksnames segment should be used, in this way, the source disk and path of all files can be simply expressed.
10. ceshortcuts
[Ceshortcuts] is optional and appears in the defaultinstall section. It is used to specify the shortcut created by the installation process on the device. The ceshortcuts = shortcuts additional section defined in front of it. We need to complete the work of adding a shortcut to the program.
[Shortcuts]
% Appname %, 0, atz. lnk, % ce17 %
Syntax: "menu name", marker number, target file, target directory
Here we use the macro string defined above and the default macro of the system, so that we can implement atz. the lnk shortcut is added to the Windows/Start Menu directory and named "Mobile Data Center" in the menu ". The number of signs is required. Specifies whether the shortcut is an integer pointing to a file or a folder. Zero or null indicates the shortcut to the file, and non-zero indicates the shortcut to the folder.
Perform the cabwiz.exe syntax
After writing the INF file, you should note that cabwiz is used to package and generate the installation file.
Syntax:
Cabwiz.exe "inf_file_and_path" [/DEST dest_directory] [/err error_file] [/CPU cpu_type [cpu_type]
Inf_file_and_path is required. String used to specify the complete path and file name for the. inf file.
Dest_directory is optional. Parameters used to specify the target directory for the cab. If you do not specify a directory, cabwiz.exe will create a cab file in the directory where the. inf file resides.
Error_file is optional. This log file is created to contain all errors and warnings generated when the cab file is compiled. If the file name is used, the user interface is not displayed when cabwiz.exe displays the message, which is useful for Automatic Generation. If the file name is not specified, cabwiz.exe displays a warning and error in the message box.
Cpu_type is optional. This parameter is used to specify the parameters of each processor for which the cab file is to be created. /The CPU parameter must appear as the final parameter on the command line, followed by multiple cpu_type values.
I am the simplest, dedicated CPU class, And put cabwiz.exe and its related programs under my current directory,
Name the INF file app. INF. My simple example is as follows:
Cabwiz "app. inf"/err log.txt
If a problem is identified, log.txt records all the information. Sometimes it also sends out some information that can be skipped, such as telling you that the macro you define is not used,
Seven, written at the end
Finally, the most common cause is punctuation. I am most afraid of trouble. I think the best practice is not to use the special usage mentioned below. If you cannot avoid it, you should be careful.
1. In the. inf file, use the semicolon (;) to start each comment line .. The inf file analyzer skips a line with the semicolon and displays any character after the semicolon, unless the semicolon contains a string enclosed by quotation marks (") or percent sign (%), for example, "stri; ng" or % stri; ng %.
2. When using string replacement or string keywords (such as appname), enclose them with a percent sign (%. Two Adjacent percent signs (%) are used to represent the % characters in the string keyword name.
3. Insert a backslash (/) to the position where you want to disconnect the item. You can continue writing the item in the next line. However, if an item or command specifies a value ending with a backslash (such as a directory path), enclose the string or backslash in quotation marks. For example, you can use/programs/mytestapps "/" or "/programs/mytestapps/" to reinterpret the backslash as a row continuation character.
4. Use commas (,) to separate the values provided in the section. When you omit an optional value in the Value List, you must retain a comma. HoweverOperating System. Inf file can omit the suffix comma.
5. Use an underscore (_) to indicate spaces in the string keyword name.