Creating a Process (Windows Embedded CE 6.0)
1/6/2010
To start a process from within another process, call the CreateProcess function, which loads a new application into memory and creates a process with at least one thread.
The following code example shows the CreateProcess function prototype:
BOOL CreateProcess(LPCTSTR lpApplicationName,
LPTSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment,
LPCTSTR lpCurrentDirectory, LPSTARTUPINFO lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation );
Because Windows Embedded CE does not support security or current directories and does not handle inheritance, most parameters must be set to NULL or zero.
The following code example shows the function prototype when all unsupported functionality is taken into consideration:
BOOL CreateProcess(LPCTSTR lpApplicationName,
LPTSTR lpCommandLine, NULL, NULL, FALSE,
DWORD dwCreationFlags, NULL, NULL, NULL,
LPPROCESS_INFORMATION lpProcessInformation );
The first parameter, lpApplicationName, must contain a pointer to the name of the application to start. Windows Embedded CE does not support passing NULL for lpApplicationName and looks for the application in the following directories, in the following order:
- The path specified in lpApplicationName, if one is listed
- The Windows directory
- The root directory in the object store (\)
- An OEM-specified search path
The lpCommandLine parameter specifies the command line to pass to the new process. The command line must be passed as a Unicode string.
The dwCreationFlags parameter specifies the initial state of the process after loading.
The following table describes all supported flags.
Flag | Description |
---|---|
0 |
Creates a standard process. |
CREATE_SUSPENDED |
Creates a process with a suspended primary thread. |
DEBUG_PROCESS |
Creates a process to be debugged by the calling process. |
DEBUG_ONLY_THIS_PROCESS |
Creates a process to be debugged by the calling process, but does not debug any child processes that are launched by the process being debugged. This flag must be used with DEBUG_PROCESS. |
CREATE_NEW_CONSOLE |
Creates a console. |
The last parameter used by CreateProcess is lpProcessInformation. This parameter points to the PROCESS_INFORMATION structure, which contains data about the new process. This parameter can also be set to NULL.
If the process cannot run, CreateProcess returns FALSE. For more information about the failure, call the GetLastError function.