标签:
// windows_33_Proc_windows_job.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <windows.h>
#include <conio.h>
HANDLE Create( LPSTR pszPath )
{
//创建一个进程,把句柄返回,交给后续的函数来处理
STARTUPINFO si = { 0 };
PROCESS_INFORMATION pi = { 0 };
si.cb = sizeof( si );
CreateProcess( pszPath, NULL, NULL, NULL, FALSE,
NULL, NULL, NULL, &si, &pi );
return pi.hProcess;
}
void Job( )
{
//1、创建一个作业
//CreateJobObject
HANDLE hJob = CreateJobObject( NULL, "MyJob" );
//2、设置作业权限
//SetInformationJobObject
JOBOBJECT_BASIC_UI_RESTRICTIONS ui = { 0 };
ui.UIRestrictionsClass = JOB_OBJECT_UILIMIT_READCLIPBOARD | JOB_OBJECT_UILIMIT_WRITECLIPBOARD;
SetInformationJobObject( hJob, JobObjectBasicUIRestrictions,
&ui, sizeof( ui ) );
//创建进程
HANDLE hProc = Create( "G:\\软件存盘包\\Note\\notebook.exe" );
HANDLE hProc1 = Create( "G:\\软件存盘包\\Note\\notebook.exe" );
//3、将进程加入作业
//AssignProcessToJobObject
AssignProcessToJobObject( hJob, hProc );
AssignProcessToJobObject( hJob, hProc1 );
getchar( );
//结束作业
TerminateJobObject( hJob, 0 );
//4、关闭作业
//CloseHandle
CloseHandle( hJob );
}
int _tmain(int argc, _TCHAR* argv[])
{
Job( );
return 0;
}
33 windows_33_Proc_windows_job 进程,windows作业
标签:
原文地址:http://www.cnblogs.com/nfking/p/5573568.html