Export (0) Print
Expand All
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Creating a Process

Windows Mobile 6.5
A version of this page is also available for
4/8/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 Mobile 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 Mobile does not support passing NULL for lpApplicationName and looks for the application in the following directories, in the following order:

  1. The path specified in lpApplicationName, if one is listed
  2. The Windows directory
  3. The root directory in the object store (\)
  4. 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.

Community Additions

Show:
© 2015 Microsoft