提交当前本机整理版本
This commit is contained in:
@@ -365,4 +365,25 @@ namespace Lskj.Util
|
||||
JOBOBJECT_BASIC_LIMIT_INFORMATION info = new JOBOBJECT_BASIC_LIMIT_INFORMATION();
|
||||
info.LimitFlags = 0x2000;
|
||||
JOBOBJECT_EXTENDED_LIMIT_INFORMATION extendedInfo = new JOBOBJECT_EXTENDED_LIMIT_INFORMATION();
|
||||
extendedI
|
||||
extendedInfo.BasicLimitInformation = info;
|
||||
//Design by LeventureQys
|
||||
int length = Marshal.SizeOf(typeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION));
|
||||
IntPtr extendedInfoPtr = Marshal.AllocHGlobal(length);
|
||||
Marshal.StructureToPtr(extendedInfo, extendedInfoPtr, false);
|
||||
|
||||
if (!SetInformationJobObject(job_handle, JobObjectInfoType.ExtendedLimitInformation, extendedInfoPtr, (uint)length))
|
||||
throw new Exception(string.Format("Unable to set information. Error: {0}", Marshal.GetLastWin32Error()));
|
||||
}
|
||||
/// <summary>
|
||||
/// 为该dll注册子进程,当主程序崩溃的时候,子进程一样退出
|
||||
/// </summary>
|
||||
/// <param name="added_process"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddProcess(IntPtr intPtr)
|
||||
{
|
||||
System.IntPtr handle = System.IntPtr.Zero;
|
||||
handle = intPtr;
|
||||
return AssignProcessToJobObject(job_handle, handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user