SVN r648
SVN-Revision: r648
This commit is contained in:
@@ -162,6 +162,47 @@ namespace Lskj.Util
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 重置位置
|
||||
/// </summary>
|
||||
/// <param name="exeMainHandle"></param>
|
||||
/// <param name="control"></param>
|
||||
public static void ResizeEmbeddedWindow(IntPtr exeMainHandle, System.Windows.Forms.Control control)
|
||||
{
|
||||
if (exeMainHandle == IntPtr.Zero)
|
||||
return;
|
||||
MoveWindow(exeMainHandle, 0, 0, control.Width, control.Height, true);
|
||||
}
|
||||
/// <summary>
|
||||
/// 把 string[] 类型的参数数组转换为单个命令行字符串,自动添加引号并转义
|
||||
/// </summary>
|
||||
public static string CombineArgs(string[] args)
|
||||
{
|
||||
if (args == null || args.Length == 0)
|
||||
return string.Empty;
|
||||
|
||||
// 简单处理:遇到有空格或特殊符号,加双引号包裹
|
||||
// 并转义内部双引号
|
||||
var combined = new System.Text.StringBuilder();
|
||||
foreach (var arg in args)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(arg))
|
||||
{
|
||||
combined.Append("\"\"");
|
||||
}
|
||||
else if (arg.Contains(" ") || arg.Contains("\""))
|
||||
{
|
||||
string escaped = arg.Replace("\"", "\\\"");
|
||||
combined.Append("\"").Append(escaped).Append("\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
combined.Append(arg);
|
||||
}
|
||||
combined.Append(" ");
|
||||
}
|
||||
return combined.ToString().TrimEnd();
|
||||
}
|
||||
/// <summary>
|
||||
/// 遍历窗口并查找窗口相关WindowInfo信息
|
||||
/// </summary>
|
||||
/// <param name="match"></param>
|
||||
@@ -293,25 +334,4 @@ 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();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
extendedI
|
||||
Reference in New Issue
Block a user