Книга: Microsoft Windows Embedded CE 6.0 Exam Preparation Kit

HKEY_LOCAL_MACHINEINIT Registry Key

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.

Оглавление книги

Оглавление статьи/книги

Генерация: 1.084. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз