作业问题,附上全部源代码,高手请指教

universee universee 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

#include <windows.h>
//#include <windowsx.h>
#include <process.h> // for _beginthreadex
#include <tchar.h>
#include <stdio.h>

void main()
{
//Create a job kernel object.
HANDLE hjob =CreateJobObject(NULL,NULL);

//Place some restrictions on processes in the job.
//First,set some basic restrictions.
JOBOBJECT_BASIC_LIMIT_INFORMATION jobli = { 0 };

//The process always runs in the idle priority class.
jobli.PriorityClass = IDLE_PRIORITY_CLASS;

//The job cannot use more than 1 second of CPU time.
jobli.PerJobUserTimeLimit.QuadPart = 10000000;
//1 sec in 100-ns intervals

//These are the only 2 restrictions I want placed on the job (process).
jobli.LimitFlags = JOB_OBJECT_LIMIT_PRIORITY_CLASS |
JOB_OBJECT_LIMIT_JOB_TIME;

SetInformationJobObject(hjob,
JobObjectBasicLimitInformation,
&jobli, sizeof(jobli));

//Second, set some UI restrictions.
JOBOBJECT_BASIC_UI_RESTRICTIONS jobuir;
jobuir.UIRestrictionsClass = JOB_OBJECT_UILIMIT_NONE;
//A fancy zero

//The process can't log off the system.
jobuir.UIRestrictionsClass |= JOB_OBJECT_UILIMIT_EXITWINDOWS;

//The process can't access USER objects
//(such as other windows) in the system.
jobuir.UIRestrictionsClass |= JOB_OBJECT_UILIMIT_HANDLES;

SetInformationJobObject(hjob,JobObjectBasicUIRestrictions,
&jobuir, sizeof(jobuir));

//Spawn the process that is to be in the job.
//Note: You must first spawn the process and then place the process in
//the job. This means that the process's thread must be initially
//suspended so that it can't execute any code outside
//of the job's restrictions.

STARTUPINFO si = { sizeof(si) };
PROCESS_INFORMATION pi;
CreateProcess(NULL, "CMD", NULL, NULL, FALSE,
CREATE_SUSPENDED, NULL, NULL, &si, &pi);
//Place the process in the job.
//Note:if this process spawns any children,the children are
//automatically part of the same job.
AssignProcessToJobObject(hjob,pi.hProcess);

//Now we can allow the child process's thread to execute code.
ResumeThread(pi.hThread);
CloseHandle(pi.hThread);

//Wait for the process to terminate or for all the job's
//allotted CPU time to be used.
HANDLE h[2];
h[0] = pi.hProcess;
h[1] = hjob;
DWORD dw = WaitForMultipleObjects(2,h,FALSE,INFINITE);
switch( dw-WAIT_OBJECT_0 )
{
case 0:
//The process has terminated...
break;
case 1:
//All of the job's allotted CPU time was used...
break;
}

//Clean up properly.
CloseHandle(pi.hProcess);
CloseHandle(hjob);
}


这些函数都找不到,为什么?明明都是在windows中的呀
/------------------

(10) : error C2065: 'CreateJobObject' : undeclared identifier
(10) : error C2440: 'initializing' : cannot convert from 'int' to 'void *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
(27) : error C2065: 'SetInformationJobObject' : undeclared identifier
(59) : error C2065: 'AssignProcessToJobObject' : undeclared identifier
(91) : error C2373: 'AssignProcessToJobObject' : redefinition; different type modifiers
(96) : error C2373: 'CreateJobObject' : redefinition; different type modifiers
(103) : error C2373: 'SetInformationJobObject' : redefinition; different type modifiers
...全文

相关推荐

Python项目-实例-31 wxpy获取微信好友头像.zip

Python课程设计,含有代码注释,新手也可看懂。毕业设计、期末大作业、课程设计、高分必看,下载下来,简单部署,就可以使用。 包含:项目源码、数据库脚本、软件工具等,该项目可以作为毕设、课程设计使用,前后端代码都在里面。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。

chusheng1840

python实例-31 wxpy获取微信好友头像.zip源码python项目实例源码打包下载

python实例-31 wxpy获取微信好友头像.zip源码python项目实例源码打包下载python实例-31 wxpy获取微信好友头像.zip源码python项目实例源码打包下载python实例-31 wxpy获取微信好友头像.zip源码python项目实例源码打包下载python实例-31 wxpy获取微信好友头像.zip源码python项目实例源码打包下载 1.合个人学习技术做项目参考合个人学习技术做项目参考 2.适合学生做毕业设计项目参考适合学生做毕业设计项目技术参考 3.适合小团队开发项目技术参考适合小团队开发项目技术参考

yxkfw

python源码-案例框架-实例-31 wxpy获取好友头像.zip

python源码-案例框架-实例-31 wxpy获取好友头像.zip

徐浪老师

基于python的实例-31 wxpy获取好友头像.zip

基于python的实例-31 wxpy获取好友头像.zip

程序员添宇

实例-31 wxpy获取微信好友头像.zip

绝不打广告求通过!有冒犯平台规则处请消息告知,我会积极整改!求审核人员不要封我号!我绝不违法乱纪! 有问题请及时告知我!十分感谢! 本人亲自运行,所有项目都有运行视频,有问题看我主页!

软件定制毕业软考事业编国企公务员
评论 10
收藏 已收藏
分享
返回顶部
universee
VC/MFC 16,550 成员 421,606 内容