CreateProcessInternalW
The CreateProcessInternalW function creates a new process and its primary thread. The new process runs in the same logon session as the calling process.
Syntax
BOOL CreateProcessInternalW(
[in] HANDLE hToken,
[in, optional] LPWSTR lpCommandLine,
[in, optional] LPSECURITY_ATTRIBUTES lpProcessAttributes,
[in, optional] LPSECURITY_ATTRIBUTES lpThreadAttributes,
[in] BOOL bInheritHandles,
[in] DWORD dwCreationFlags,
[in, optional] LPVOID lpEnvironment,
[in, optional] LPCWSTR lpCurrentDirectory,
[in] LPSTARTUPINFOW lpStartupInfo,
[out] LPPROCESS_INFORMATION lpProcessInformation
);
Parameters
| Parameter | Type | Description |
|---|---|---|
hToken |
HANDLE |
A handle to the primary access token of the process to be created. This token must be enabled for impersonation. If this parameter is NULL, the new process inherits the primary access token of the calling process.
This parameter is reserved for system use, and must be NULL. |
lpCommandLine |
LPWSTR |
The command line for the process to be created. This parameter can be NULL. If it is NULL, the function returns If this parameter is an empty string, the return value is The recommended method for creating a process is to specify the application name and command-line arguments separately, for example:
|
lpProcessAttributes |
LPSECURITY_ATTRIBUTES |
A pointer to a If |
lpThreadAttributes |
LPSECURITY_ATTRIBUTES |
A pointer to a STARTUPINFOW structure that specifies the window station, desktop, standard handles, and appearance of the main window for the new process. This parameter can be NULL. |
bInheritHandles |
BOOL |
If this parameter is If the calling process is running under a debugger, the debugger can override this parameter and specify whether the handles are inherited. |
dwCreationFlags |
DWORD |
Flags that control the priority class and behavior of the new process. This parameter can be a combination of the following values:
|
lpEnvironment |
LPVOID |
A pointer to a null-terminated Unicode string that specifies the environment variables for the new process. If this parameter is NULL, the new process inherits the environment of the calling process. The environment block is a null-terminated array of null-terminated strings. Each string is of the form:
The last string in the block is followed by two null characters: one for the string terminator and one for the block terminator. |
lpCurrentDirectory |
LPCWSTR |
A pointer to a null-terminated Unicode string that specifies the full path of the current directory for the new process. If this parameter is NULL, the new process inherits the current directory of the calling process. |
lpStartupInfo |
LPSTARTUPINFOW |
A pointer to a |
lpProcessInformation |
LPPROCESS_INFORMATION |
A pointer to a |
Return Value
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
The CreateProcessInternalW function is the internal routine used by the operating system to create processes. It is generally recommended to use the CreateProcessW function for creating processes in user-mode applications.
If lpCommandLine is NULL, the function fails and returns FALSE.
If lpStartupInfo points to a STARTUPINFOW structure, the cb member of that structure must be set to the size of the structure.
The hToken parameter is reserved for system use and must be NULL.
If the calling process is a 32-bit application, it can create a 64-bit process if the operating system supports it. If the calling process is a 64-bit application, it can only create 64-bit processes.
The dwCreationFlags parameter can be used to control various aspects of the new process. For example, you can create a process in a suspended state by using the CREATE_SUSPENDED flag, and then resume it later using the ResumeThread function.
The environment block is inherited from the parent process by default. If you want to provide a custom environment block, you must format it correctly as a null-terminated array of null-terminated strings.
Requirements
Minimum supported client: Windows XP with SP2
Minimum supported server: Windows Server 2003 with SP1
Header: ProcessThreadsAPI.h
Library: Kernel32.lib
DLL: Kernel32.dll
Unicode and ANSI versions: CreateProcessInternalW (Unicode) and CreateProcessInternalA (ANSI) are available.