The standard shell for Windows CE looks somewhat similar to Windows 95/Windows 2000 with the Start Menu, task bar, desktop, and icons/shortcuts. If you build a CE 6.0 image based on the PDA template you get the standard shell which includes one program on the start menu, this is the "File Explorer". So how do you add your own applications to the Start Menu?

FileExplorer

The first thing to determine is exactly where the Start Menu appears in the operating system. We can use the Remote File Viewer to examine a running operating system image. Here's the \Windows folder tree from the running operating system image - you can see that I've highlighted the \Windows\Programs folder on the left side of the File Viewer application, the right side shows the contents of the \Windows\Programs folder - here we can see the "Windows Explorer.lnk" file - this is a shortcut to the actual "Windows Explorer" application, which lives in the \Windows folder (I have a comment about this later...)

RemoteFileViewer

So, what does the "Windows Explorer.lnk" file contain? - let's go take a look the build release folder. For my Windows CE project (called StartMenu) the build release folder is going to be C:\WINCE600\OSDesigns\StartMenu\StartMenu\RelDir\DeviceEmulator_ARMV4I_Release.

A quick search for "Windows Explorer.lnk" doesn't find anything, but there is a .lnk file called "explore.lnk", could this be the "Windows Explorer.lnk" file we're looking for?

Here's the contents of the file...

21#\windows\explorer.exe

This is how a shortcut is formatted (similar to a BSTR), the number of characters in the string, followed by the string - go ahead, count them... yep, there's 21 characters in the path to the executable. This is the shortcut file we're looking for, but doesn't have the right name, we're looking for "Windows Explorer.lnk".

To include a file into the operating system image we need to edit a BIB (Binary Image Builder) file, this contains two "sections", one called "MODULES" which contains a list of executable items (EXE's and DLL's) and the other called "FILES" which contains non-executable content (wav files, documents, oh, and also contains .NET Compact Framework applications, which may have the extension '.EXE', but aren't real applications, they adhere to the PE (Portable Executable) format, but are not executable without the underlying .NET runtime - the Compact Framework applications are in a format called MSIL (or MicroSoft Intermediate Language). Anyhow, back to the investigation - the Windows CE build system may contain a number of .BIB files - here's a list of BIB files from my sample project.

ce.bib
cellcore.bib
common.bib
config.bib
datasync.bib
dcom.bib
gdiex.bib
ie.bib
netcfv2.bib
platform.bib
project.bib
script.bib
servers.bib
shell.bib
shellsdk.bib
sqlce.bib
wceappsfe.bib
wceshellfe.bib

Note that I've highlighted the file CE.BIB file, this is one of a number of special files that get created by the Windows CE build system - the file CE.BIB can be thought of as a compilation of all of the individual BIB files from the build system - we will continue our investigation in the CE.BIB file.

Here's a line from the CE.BIB file, note that I've compressed the path from the full Build Release Folder to fit on the page.

explore.lnk           C:\WINCE600\....\explore.lnk              NK SH

Hmm... the file still appears to be shown as explore.lnk - so the mapping to "Windows Explorer.lnk" must happen somewhere else.

Next stop on the trail is the .DAT files, again, there are a number of these files that are used by the build system, and much like CE.BIB these get pulled together into a single file called Initobj.dat - let's examine the content of the initobj.dat file. Here's an extract from the file...

Directory("\Windows"):-Directory("Programs")
Directory("\Windows"):-Directory("Recent")

; @CESYSGEN IF SHELL_MODULES_EXPLORER
Directory("\Windows\Programs"):-File("Windows Explorer.lnk", "\Windows\explore.lnk")

The .DAT file are use to do two specific things, the first is to create folders within the Windows CE operating system, the second is to map files from the \Windows folder into one of these other folders.

So, we can see above the \Windows\Programs folder being created, as well as the creation of the \Windows\Recent folder.

Even more interesting is the mapping of the \Windows\explore.lnk file into the \Windows\Programs folder, and at the same time being renamed to "Windows Explorer.lnk"

So here's the list of steps needed to get a file onto the Start menu.

  1. Create your file (and a shortcut to the file - this is a .lnk file [see above for the format])
  2. Add the file, and the shortcut to an appropriate .BIB file
  3. Create the mapping of shortcut file from the \Windows Folder to the \Windows\Programs folder (use a .DAT file to make the mapping)

And don't forget to make sure the file, and the shortcut are somehow magically placed into your build output folder during the operating system build process.

That's all there is to it! - And now onto my comment... When you build a Windows CE operating system image ALL of the files that make up that image are placed into the \Windows folder (obviously you can create folders, and drop files into other folders on a running operating system image) and you need to use .DAT files to map these files to other folders in the operating system - wouldn't it be useful to have an extension to the .BIB file format so that a file doesn't have to appear in the \Windows folder in the first place and could be directly mapped to the folder you wanted it to be in?

- Mike