A desired function prototypes
Function prototype
1
2
3
4
5
6
7
8
9
10
11
12
13
|
BOOL
CreateProcess
(
LPCTSTR
lpApplicationName,//对象名称
LPTSTR
lpCommandLine,//命令行
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL
bInheritHandles,
DWORD
dwCreationFlags,
LPVOID
lpEnvironment,
LPCTSTR
lpCurrentDirectory,
LPSTARTUPINFO lpStartupInfo,
LPPROCESS_INFORMATIONlpProcessInformation
);
|
STARTUPINFO for a characteristic structure of the main window to specify a new process. (IN parameter)
The main details are stored to create a variety of child process
CreateChildProcess BOOL (PTCHAR szChildProcessName, PTCHAR szCommandline) // create a child process { the STARTUPINFO Si; the PROCESS_INFORMATION PI; ZeroMemory ( & PI, sizeof (PI)); ZeroMemory ( & Si, sizeof (Si)); si.cb = sizeof (Si); // this structure inside the required IF (! CreateProcess ( szChildProcessName, // object name szCommandline, // command line NULL, // no succession process handle NULL, //Not inherit thread handle FALSE, // not inherit handles 0 , // do not create sign NULL, // parent process environment variable is NULL, // parent process directory as the current directory & Si, // STARTUOINFOW structure & PI )) { } }
PROCESS_INFORMATION (OUT parameter)
PROCESS_INFORMATION structure
typedef struct_PROCESS_INFORMATION{
HANDLE hProcess;
HANDLE hThread;
DWORD dwProcessId;
DWORD dwThreadId;
}PROCESS_INFORMATION;
Where the members have the following meanings.
① hProcess: returns a handle to the new process.
② hThread: return to
the main thread
handle.
③ dwProcessId: Returns a global process
identifier
. This identifier is used to identify a process. The process is
Created to termination, the value is always valid.
④ dwThreadId: Returns a global
thread
identifier. This identifier is used to identify a thread. From the thread is hit
Built to terminate, the value is always valid.