private void checkProcessAndClose(Process pro, string name) { ushort handle = RefreshHandles(pro, name); if (handle != 0) { HandleModle.CloseProcessHandle(pro.Id, handle); } }
private ushort RefreshHandles(Process pro, string check = "") { List <Win32API.SYSTEM_HANDLE_INFORMATION> lws = HandleModle.GetHandles(pro); foreach (Win32API.SYSTEM_HANDLE_INFORMATION lw in lws) { string str_handle_name = HandleModle.GetFilePath(lw, pro); if (str_handle_name == "") { continue; } if (str_handle_name == null) { continue; } if (str_handle_name.Contains(check)) { return(lw.Handle); } } return(0); }