Creating Processes-创建进程
来源:互联网 发布:php应用开发是干嘛的 编辑:程序博客网 时间:2024/06/06 01:34
The CreateProcess function creates a new process, which runs independently of the creating process. However, for simplicity, the relationship is referred to as a parent-child relationship.
此函数创建一个新的线程,新的线程是独立运行的. 简单的讲,他们的关系是主进程与子进程的关系.
可执行代码
#include <windows.h>#include <stdio.h>#include <tchar.h>void _tmain(int argc, TCHAR *argv[]){STARTUPINFO si;PROCESS_INFORMATION pi;ZeroMemory(&si, sizeof(si));si.cb = sizeof(si);ZeroMemory(&pi, sizeof(pi));if (argc != 2){printf("Usage: %s [cmdline]\n", argv[0]);// 如 CreatProcesses aaa.exe // 程序将会启动并切换到 aaa.exe ,等aaa.exe执行. return;}// Start the child process. if (!CreateProcess(NULL, // No module name (use command line)argv[1], // Command lineNULL, // Process handle not inheritableNULL, // Thread handle not inheritableFALSE, // Set handle inheritance to FALSE0, // No creation flagsNULL, // Use parent's environment blockNULL, // Use parent's starting directory &si, // Pointer to STARTUPINFO structure&pi) // Pointer to PROCESS_INFORMATION structure){printf("CreateProcess failed (%d).\n", GetLastError());return;}// Wait until child process exits.WaitForSingleObject(pi.hProcess, INFINITE);// Close process and thread handles. CloseHandle(pi.hProcess);CloseHandle(pi.hThread);}
If CreateProcess succeeds, it returns a PROCESS_INFORMATION structure containing handles and identifiers for the new process and its primary thread. The thread and process handles are created with full access rights, although access can be restricted if you specify security descriptors. When you no longer need these handles, close them by using the CloseHandle function.
如果进程创建成果,则会返回一个PROCESS_INFORMATION 结构的数据, 些数据包含了新进程和句柄及标识信息,当然也包含其主线程. 当前进程可以使用创建的新的进程及其线程,如果声明了安全规则另有限制. 当句柄使用完后可以使用CloseHandle函数关闭它.
You can also create a process using the CreateProcessAsUser or CreateProcessWithLogonW function. This allows you to specify the security context of the user account in which the process will execute.
其他的两个函数也可以用来创建线程(CreateProcessAsUser 及 CreateProcessWithLogonW). 它们可以让你指定它运行在的用户类别的安全上下文信息.
-------------------
翻译暂存,后续修改.
- Creating Processes-创建进程
- processes 1 启动进程
- 26. Processes (进程)
- Understanding the linux kernel-ch3-Creating Processes
- Creating Processes: Sessions and Integrity Levels
- Processes(进程)相关介绍
- 进程优先级 processes and Threads
- Processes
- Processes
- 1.6.程序和进程(Programs and Processes)
- 1.3 Processes and cProcessManager(进程和cProcessManager)
- Processes and Threads 进程和线程
- Oracle后台进程之:Slave Processes
- Oracle Background Processes -oracle 后台进程介绍
- 如何干掉一组进程,kill group processes
- Processes and Threads//进程和线程
- 进程和线程-Processes and Threads[译文]
- Processes and Threads(进程与线程)
- json 学习之(json基础)
- 细说mysql索引
- Boost智能指针——shared_ptr
- H5中的快
- 2017暑假七林集训day23
- Creating Processes-创建进程
- Java面试题目
- The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- PLSQL块结构
- 51Nod-1624-取余最短路
- 如何控制回撤
- jsp基础
- Dockerfile注意事项
- spring jar作用