Http://msdn.microsoft.com/zh-cn/library/zcebx8f8 (vs.80). aspx
This walkthrough demonstrates how to use Visual Studio 2005 to package an application and its resources into a cab file so that it can be deployed on an end user's smart device.
In this walkthrough, you can start with any smart device solution written in Visual Basic 2005, Visual C #2005, or visual C ++ 2005. For more information, see Walkthrough: creating a simple application.
This walkthrough demonstrates how to perform the following operations:
Add a cab project to the solution.
Change the product name.
Change the output path.
Fill in the cab file with the main output of the application.
Add dependencies when necessary.
The shortcut for creating an application.
Edit the registry key.
Prerequisites: an existing smart device solution. For this packaging drill, you can consider creating and generating a simple project
Install the cab Project
Add a smart device cab project for the solution
Open an existing smart device project and make sure that Solution Explorer is visible.
On the File menu, point to add and click Create project ".
The "Add new project" dialog box appears.
Expand the "other project types" node in the "project type" Pane on the left, and then click "Install and deploy ".
In the template pane on the right, select smart device cab project ".
This is the only cab project type that can be used for smart devices. Other project types are only used for desktop solutions.
In the Name box, typeCabprojectAnd then click OK ".
This cab project is added to your solution and displayed in Solution Explorer. The "File System Editor" pane is displayed.
Custom cab Project
Change product name and other project properties
In Solution Explorer, select cabproject (if not selected ).
Click attribute window on the View menu or open the attribute window.
In the "productname" Field of the property grid, change the value to "myproduct ".
The value of the "productname" attribute determines the name displayed for the application in the folder name and "add or delete programs" dialog box.
You can also use this window to change the manufacturer name and specify the minimum and maximum operating system versions allowed.
You can set the "osversionmin" attribute to 4.21 to indicate that your Pocket PC application has the screen orientation awareness function. However, setting this attribute to 4.21 will prevent applications from being installed on Windows Mobile 2003 or earlier Pocket PCs. To allow installation of the Program on such devices and notify newer devices that the program has the screen orientation function, you must manually edit the program. INF file, set the "buildmax" attribute to one of the following values:
0xa0000000, indicating that the application supports a square screen (240x240 pixels)
0xc0000000, indicating that the application supports screen Rotation
-Or-
0xe0000000 indicates that the application supports square screen and screen rotation.
For more information, see the msdn White Paper "Developing screen orientation-aware applications" (development of applications that recognize the screen direction ).
For Pocket PC solutions based on Windows Mobile 2003se and earlier versions, the "compress" attribute and "nouninstall device deployment" attribute must be false. Note that for devices with Compact Framework 2.0, this option can be setTrue. For more information, see the smart device cab project> Properties window.
If you are using Windows CE Installer DLL, you can use this attribute grid to specify the file name and location. For more information about Windows CE Installer DLL, see the Pocket PC or smartphone SDK documentation.
Change the name of the cab file and add Authentication
In Solution Explorer, right-click "cabproject" and click "properties ".
The "property page" dialog box for the cab project appears. In the output file name box, change the name and path of the cab fileDebug/MyApp. CabAnd then click OK ".
You can also use this property page to add authentication for the project. Authentication is required for the smartphone solution, but authentication is not supported in Pocket PC solutions based on Windows Mobile 2003 se and earlier versions. For more information, see Security in device projects.
Add a device project application to the cab Project
In the left pane of the file system Editor, select the application folder node to specify that the files selected in the following steps will be installed in this folder on the target device.
If the file system editor is invisible, right-click the cab project name in Solution Explorer, select view, and click File System ".
In Visual Studio, point to "add" on the "operations" menu, and click "project output ".
In the Add project output group dialog box, select your smart device project from the project drop-down list.
Select "main output" from the output list and click "OK ".
Note: |
When creating a smart device cab project for applications written in C ++, to dynamically link to the DLL, you must manually add all dependencies to the cab project, such as atl80.dll and mfc80u. DLL and/or msvcr. DLL. However, we strongly recommend that you use static links to reduce the dependencies of the MFC/atl dll. If static links are used, you do not need to re-release the DLL along with the application. If dynamic links are used and DLL needs to be re-released in the cab, do not install the dll in the system directory (such as/Windows) on the device, instead, install the DLL in the local application directory. If you re-release an application suite, and all applications in the suite are dynamically linked to the ATL/mfc Runtime library, we recommend that you install all applications and runtime DLL in a separate application directory and provide shortcuts for applications that can be placed in your own folder. In this way, the dll in the system directory can be replaced in the future, thereby damaging the risk of any application that dynamically links to these DLL, and saving some space. |
Add dependencies to the cab Project (C ++ projects only)
In Solution Explorer, right-click the name of the cab project, point to add, and then click File ".
Navigate to <Visual Studio installation folder>/VC/CE/dll/<platform>.
Select the file to add.
For an MFC project, press Ctrl and then click mfc80u. dll, atl80.dll, and msvcr80.dll. If the application requires resources specific to the MFC language, you may need to click one or more language-specific DLL.
For the ATL Project, press Ctrl and then click atl80.dll and msvcr80.dll. If the ATL solution supports MFC, click mfc80u. dll.
For Win32 projects, click msvcr80.dll.
In the Add file dialog box, click open to add the file to the cab project.
In the left pane of the file system Editor, right-click File System on the target computer ".
Click Add special folder, and then click Windows folder ".
In the left pane of the file system Editor, click the folder that contains the main output. By default, dll has been added to the same folder as the main output. To move these DLL files to the Windows folder, select these files in the middle pane of the file system editor and drag them to the Windows folder icon.
Add any other Dependencies required by the solution using the same process. You can add dependencies to any folder without adding them to the Windows folder.
Create shortcuts for device project applications
In the right pane of the file system Editor, select "main output of <your application project name> ".
On the "operations" menu, select "create master output shortcut for <your application project name> ".
This command adds a shortcut under the "output" item.
Right-click the shortcut item and click "RENAME" to rename the shortcut to the content suitable for the shortcut.
Add registry key
In Solution Explorer, select the cab project.
On the "View" menu, point to "Editor" and click "Registry ".
In Registry Editor, right-click HKEY_CURRENT_USER, and then click new item on the shortcut menu ".
When the new entry is displayed in the Registry Editor, rename it to software ".
Right-click the new item, point to "new", and click "item ".
When the new entry is displayed in the Registry Editor, rename it "mycompany ".
Right-click "mycompany" and click "Properties window" on the shortcut menu ".
The value of "name" has been changed to "mycompany ". Generate and deploy the cab file
Generate and deploy the cab file
Generate a cab file
Click Generate cabproject on the generate menu ".
-Or-
In Solution Explorer, right-click "cabproject" and click "generate ".
Click Save all on the File menu ".
The cab file of the smartphone solution must be digitally signed before being deployed to the end user's device. The Pocket PC Solution Based on Windows Mobile 2003se and earlier does not support digital signatures. For more information, see How to: sign the cab file (device ).
Deploy the cab file on the device
Find the folder that stores the solution in Windows Resource Manager. You can find this cab file in the "cabproject/release" folder of the solution.
Copy the cab file to a device connected to ActiveSync 4.0 or later.
When you click the cab file name in "Resource Manager" on the device, Windows CE unlocks the cab and installs the application on the device.
For more information, see the smartphone and Pocket pc sdk documentation.