a graphical or command-line interface, but system applications are typically started automatically as part of the operating system.
Start an Application at Startup
You can configure applications to start automatically as part of the Windows Embedded CE initialization process. This feature can be set in several ways, depending on whether you want to run the applications before or after Windows Embedded CE loads the shell user interface (UI). One method is to manipulate several registry settings that control the application startup behavior. Another common method is to place a shortcut to the application in the Startup folder so that the standard shell can start the application.
HKEY_LOCAL_MACHINEINIT Registry Key
The Windows Embedded CE registry includes several registry entries to start operating system components and applications at startup time, such as Device Manager and Graphical Windows Event System (GWES). These registry entries are located under the HKEY_LOCAL_MACHINEINIT registry key, as illustrated in Figure 3-2. You can create additional entries at this location to run your own applications included in the run-time image without having to load and run these applications manually on your target device. Among other things, automatically starting an application can facilitate debugging activities during software development.

Figure 3-2 The HKEY_LOCAL_MACHINEINIT registry key
Table 3-3 lists three examples of registry entries to start typical Windows Embedded CE components when the run-time image starts.
Table 3-3 Startup registry parameter examples
Location | HKEY_LOCAL_MACHINEINIT | ||
---|---|---|---|
Component | Device Manager | GWES | Explorer |
Binary | Launch20='Device.dll' | Launch30='Gwes.dll' | Launch50='Explorer.exe' |
Dependencies | Depend20=hex:0a,00 | Depend30=hex:14,00 | Depend50=hex:14,00,1e,00 |
Description | The LaunchXX registry entry specifies the binary file of the application and the DependXX registry entry defines the dependencies between applications. |
If you look at the Launch50 registry entry in Table 3-3, you can see that the Windows Embedded CE standard shell (Explorer.exe), will not run until process 0x14 (20) and process 0x1E (30) have started successfully, which happen to be Device Manager and GWES. The hexadecimal values in the DependXX entry refer to decimal launch numbers XX, specified in the name of the LaunchXX entries.
Implementing the SignalStarted API helps the kernel manage process dependencies between all applications registered under the HKEY_LOCAL_MACHINEINIT registry key. The application can then use the SignalStarted function to inform the kernel that the application has started and initialization is complete, as illustrated in the following code snippet.
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow) {
// Perform initialization here...
// Initialization complete,
// call SignalStarted...
SignalStarted(_wtol(lpCmdLine));
// Perform application work and eventually exit.
return 0;
}
Dependency handling is straightforward. The kernel determines the launch number from the Launch registry entry, uses it as a sequence identifier, and passes it as a startup parameter in lpCmdLine to the WinMain entry point. The application performs any required initialization work and then informs the kernel that it has finished this part by calling the SignalStarted function. The call to the _wtol function in the SignalStarted code line performs a conversion of the launch number from a string to a long integer value because the SignalStarted function expects a DWORD parameter. For example, Device Manager must pass a SignalStarted value of 20 and GWES must pass a value of 30 back to the kernel for the kernel to start Explorer.exe.
The Startup Folder
If you are using the standard shell on your target device, you can drop the application or a shortcut to the application into the WindowsStartup folder of the device. Explorer.exe examines this folder and starts all found applications.
Only use the WindowsStartup folder if your target device runs the Windows Embedded CE standard shell. If you are not using the standard shell, then create a custom launch application for the same purpose and initiate it at start time based on entries under the HKEY_LOCAL_MACHINEINIT registry key. For sample code that