HANDLE CreateSandBox () {
HANDLE hjob=CreateJobObject (NULL, NULL);
If (hjob!=NULL)
{
JOBOBJECT_BASIC_LIMIT_INFORMATION jobli;
Memset (& amp; Jobli, 0, sizeof (jobli));
Jobli. LimitFlags=JOB_OBJECT_LIMIT_PRIORITY_CLASS | JOB_OBJECT_LIMIT_ACTIVE_PROCESS | | JOB_OBJECT_LIMIT_PROCESS_TIME;
Jobli. PriorityClass=IDLE_PRIORITY_CLASS;
Jobli. ActiveProcessLimit=nProcessLimit;//Limit of the processes
//jobli. MinimumWorkingSetSize=1;
//jobli. MaximumWorkingSetSize=1024 * memory_limit;
Jobli. PerProcessUserTimeLimit. QuadPart=10000 * time_limit;
If (SetInformationJobObject (hjob, JobObjectBasicLimitInformation, & amp; Jobli, sizeof (jobli)))
{
JOBOBJECT_BASIC_UI_RESTRICTIONS jobuir;
Jobuir. UIRestrictionsClass=JOB_OBJECT_UILIMIT_NONE;
Jobuir. UIRestrictionsClass |=JOB_OBJECT_UILIMIT_EXITWINDOWS;
Jobuir. UIRestrictionsClass |=JOB_OBJECT_UILIMIT_READCLIPBOARD;
Jobuir. UIRestrictionsClass |=JOB_OBJECT_UILIMIT_WRITECLIPBOARD;
Jobuir. UIRestrictionsClass |=JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS;
Jobuir. UIRestrictionsClass |=JOB_OBJECT_UILIMIT_HANDLES;
If (SetInformationJobObject (hjob, JobObjectBasicUIRestrictions, & amp; Jobuir, sizeof (jobuir)))
{
Return hjob;
}
The else
{
Write_log (" SetInformationJobObject1 JOBOBJECT_BASIC_UI_RESTRICTIONS [Error: % d] \ n ", GetLastError ());
}
}
The else
{
Write_log (" SetInformationJobObject2 JOBOBJECT_BASIC_LIMIT_INFORMATION [Error: % d] \ n ", GetLastError ());
}
}
The else
{
Write_log (" CreateJobObject [Error: % d] \ n ", GetLastError ());
}
return NULL;
}
Source code as above to remove the comments section, there is no error, but add JOB_OBJECT_LIMIT_WORKINGSET at LimitFlags error this limit will be
SetInformationJobObject2 JOBOBJECT_BASIC_LIMIT_INFORMATION [Error: 87]
GetLastError () value of 87
Solving, what reason can't JOB_OBJECT_LIMIT_WORKINGSET, is that the available memory is too small, set up 1024 * 1024 * 128128 M at the beginning, then, 1 set to 1024 K also not line, what's the matter ah