Microsoft KB Archive/268309

= How To Associate an Icon with an eVB Application =

Article ID: 268309

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft eMbedded Visual Basic 3.0

-



This article was previously published under Q268309



SUMMARY
This article describes how to distribute an eMbedded Visual Basic (eVB) application and associate a custom icon with it.



MORE INFORMATION
eVB applications are not compiled to executable files but to binary files that the Pvbload.exe executable interprets. Thus, eVB applications use the icon from Pvbload.exe in the same way that Microsoft Excel worksheets use the icon from Excel.exe. To allow for a customized application icon, you must create an eMbedded Visual C++ (eVC) application that only shells out to the operating system to run the application. The operating system recognizes that there is a file association with Pvbload.exe.

You must perform four main procedures to distribute an eMbedded Visual Basic application with a custom icon:
 * 1) Associate the icon with the eVB application.Distribute the eVC application that is required for step 1 with the eVB distribution package.Place the eVC application that is required for step 1 in the Start menu.Distribute all files successfully to multiple CPUs.
 * 2) Distribute the eVC application that is required for step 1 with the eVB distribution package.Place the eVC application that is required for step 1 in the Start menu.Distribute all files successfully to multiple CPUs.
 * 3) Place the eVC application that is required for step 1 in the Start menu.Distribute all files successfully to multiple CPUs.
 * 4) Distribute all files successfully to multiple CPUs.

Create eVB Application

 * 1) Start a new Windows CE project in eMbedded Visual Basic for your preferred target platform.
 * 2) From the File menu, click Make Project1.vb, and compile the project.
 * 3) Save the project.
 * 4) Close the project, and exit eVB.

Create eVC Application
 Start eMbedded Visual C++. From the File menu, click New. On the Project tab, click WCE Application, and provide a project name. In this example, the project is named StubLauncher. When prompted, select the option to create a simple Windows CE application.  Paste the following code over the existing WinMain function: // StubLauncher.cpp : Defines the entry point for the application. //


 * 1) include &quot;stdafx.h&quot;
 * 2) include &quot;shellapi.h&quot;

LPTSTR szAppName = _T(&quot;Project1.vb&quot;); LPTSTR szStubName = _T(&quot;StubLauncher.exe&quot;); int WINAPI WinMain( HINSTANCE hInstance,           HINSTANCE hPrevInstance,            LPTSTR    lpCmdLine,            int       nCmdShow) {  long retVal; TCHAR szPath[128]; LPTSTR Instr; LPTSTR szVerb = _T(&quot;open&quot;);

//Start the Visual Basic application and exit. SHELLEXECUTEINFO lpExecInfo; memset(&lpExecInfo, 0, sizeof(SHELLEXECUTEINFO));

lpExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);

// Get the path to the current directory. retVal = GetModuleFileName(hInstance, szPath, 128); if (retVal) { // Remove the stubs file name to get just the path. Instr = wcsstr(szPath, szStubName);

if (Instr != NULL) // Add the target file to the resulting path. wcscpy(Instr, szAppName); //MessageBox(0, szPath, _T(&quot;This is the path I got&quot;), 0);

// Now use this to start the application. lpExecInfo.lpFile = szPath; lpExecInfo.nShow = SW_SHOWNORMAL; lpExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; lpExecInfo.lpVerb = szVerb ; ShellExecuteEx(&lpExecInfo); return(0); }

return(-1); }                    Make sure that the necessary platform is selected in the WCE Configuration toolbar. From the Insert menu, click Resource, and add or import an icon for your application.</li> Make sure that the resource window for your icon is open.</li> Save the resource as an .rc file.</li> From the Build menu, click Batch Build, and compile for the necessary platforms.</li> Save all files, and exit eVC.</li></ol>

Prepare and Configure eVB Distribution Package
<ol> Start the Application Install Wizard. Use the steps in the following Microsoft Knowledge Base article to complete steps 1 through 6 of the wizard:

194837 How To Distribute a Visual Basic Windows CE Application

</li> In Step 7 of the Application Install Wizard, select the CPU-specific .exe file that you want to distribute with the eVB application.</li> Complete the Application Install Wizard.</li> Open the .inf file, and make the following changes: <ol style="list-style-type: lower-alpha;">  In the [DefaultInstall] section, change the value for CEShortcuts from &quot;Shortcuts&quot; to &quot;AddlShortcut&quot; (or whatever name you choose) as follows: <pre class="fixed_text">[DefaultInstall] CopyFiles=Files.App, Files.Windows CEShortcuts=AddlShortcut </li>  Add a new [AddlShortcut] section as follows: <pre class="fixed_text">[AddlShortcut] %AppName%,0,&quot;StubLauncher.exe&quot; </li>  In the [DestinationDirs] section, add the following line: <pre class="fixed_text">AddlShortcut=,%CE11% NOTE On PocketPC devices, add the following line: <pre class="fixed_text">AddlShortcut=,%CE2%\Start Menu </li></ol> </li> Save and close the .inf file.</li> Use the command line that is provided in the Readme.txt file to repackage the .cab file. The Readme.txt file is in the same location as the .inf file.</li> Replace the original .cab file in the CD1 directory with the newly compiled .cab file.</li></ol>

Steps to Accommodate Multiple CPUs
After you complete the preceding steps to prepare the distribution package, follow these steps: <ol> Copy the compiled CPU-specific .exe files to the CPU-specific directories where the package was created.</li> <li>Remove the compiled StubLauncher.exe from the App folder (which is in the same location where the package was created).</li> <li>Open the .inf file, and remove StubLauncher.exe from the [SourceDisksFiles] section.</li> <li> Add StubLauncher.exe to all of the CPU sections. For example: <pre class="fixed_text">[SourceDisksFiles.SH 3 (1k) v3.00] [SourceDisksFiles.Mips 4000 (4k) v3.00] </li> <li> Change the disk-ordinal to the appropriate setting. For example, if the [SourceDisksNames.SH 3 (1k) v3.00] section appears as follows: <pre class="fixed_text">3=,&quot;SH 3 (1k) v3.00 Files&quot;,,SH 3 (1k) v3.00 modify the [SourceDisksFiles.SH 3 (1k) v3.00] section as follows: <pre class="fixed_text">StubLauncher.exe=3 </li> <li>Use the command line that is provided in the Readme.txt file to repackage the .cab file. The Readme.txt file is in the same location as the .inf file.</li> <li>Replace the original .cab in the CD1 directory with the newly compiled .cab file.</li></ol>

Now you should be able to test the installation package successfully.

<div class="references_section">