Skip to content

Commit

Permalink
- 移除冗余结构,提升运行速度。
Browse files Browse the repository at this point in the history
  • Loading branch information
OdysseusYuan committed Feb 22, 2024
1 parent cc02a9c commit 31b542b
Show file tree
Hide file tree
Showing 36 changed files with 83 additions and 1,566 deletions.
167 changes: 0 additions & 167 deletions LKY_OfficeTools/Common/Com_EmailOS.cs

This file was deleted.

77 changes: 2 additions & 75 deletions LKY_OfficeTools/Common/Com_ExeOS.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* [LKY Common Tools] Copyright (C) 2022 [email protected] Inc.
* [LKY Common Tools] Copyright (C) 2022 - 2024 LiuKaiyuan. All rights reserved.
*
* FileName : Com_ExeOS.cs
* Developer: [email protected] (Odysseus.Yuan)
* Developer: [email protected] (Odysseus.Yuan)
*/

using System;
Expand All @@ -12,22 +12,10 @@

namespace LKY_OfficeTools.Common
{
/// <summary>
/// 外部 exe 文件调用类库
/// </summary>
internal class Com_ExeOS
{
/// <summary>
/// 运行 exe 类库
/// </summary>
internal class Run
{
/// <summary>
/// 启动一个外部exe,等待完成后,返回Code。
/// </summary>
/// <param name="file_path"></param>
/// <param name="args"></param>
/// <returns>执行失败时,返回:-920921</returns>
internal static int Exe(string file_path, string args)
{
try
Expand All @@ -50,14 +38,6 @@ internal static int Exe(string file_path, string args)
}
}

/// <summary>
/// 启动一个进程(带有线程信息)
/// </summary>
/// <param name="file_path"></param>
/// <param name="args"></param>
/// <param name="ProcessInfo"></param>
/// <param name="WaitForExit"></param>
/// <returns></returns>
internal static bool Process(string file_path, string args, out Process ProcessInfo, bool WaitForExit)
{
try
Expand Down Expand Up @@ -96,11 +76,6 @@ internal static bool Process(string file_path, string args, out Process ProcessI
}
}

/// <summary>
/// 运行CMD命令,并返回执行结果
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
internal static string Cmd(string args)
{
try
Expand Down Expand Up @@ -151,39 +126,17 @@ internal static string Cmd(string args)
}
}

/// <summary>
/// 结束运行 exe 类库
/// </summary>
internal class KillExe
{
/// <summary>
/// 结束进程的模式
/// </summary>
internal enum KillMode
{
/// <summary>
/// 尝试使用优雅的方式结束,如果失败,使用强制结束
/// </summary>
Try_Friendly = 1,

/// <summary>
/// 只使用优雅的方式结束,若失败,将不再尝试其他方式结束
/// </summary>
Only_Friendly = 2,

/// <summary>
/// 只使用强制模式结束进程。
/// </summary>
Only_Force = 4,
}

/// <summary>
/// 通过 进程的名称 结束指定的进程
/// </summary>
/// <param name="exe_name">不要扩展名,例如:abc.exe,此处应填写abc</param>
/// <param name="kill_mode"></param>
/// <param name="isWait">是否等待进程结束?</param>
/// <returns></returns>
internal static bool ByExeName(string exe_name, KillMode kill_mode, bool isWait)
{
try
Expand Down Expand Up @@ -211,13 +164,6 @@ internal static bool ByExeName(string exe_name, KillMode kill_mode, bool isWait)
}
}

/// <summary>
/// 通过 进程ID 结束指定的进程
/// </summary>
/// <param name="exe_id"></param>
/// <param name="kill_mode"></param>
/// <param name="isWait">是否等待进程结束?</param>
/// <returns></returns>
internal static bool ByProcessID(int exe_id, KillMode kill_mode, bool isWait)
{
try
Expand Down Expand Up @@ -277,16 +223,8 @@ internal static bool ByProcessID(int exe_id, KillMode kill_mode, bool isWait)
}
}

/// <summary>
/// 获取 exe 进程信息
/// </summary>
internal class Info
{
/// <summary>
/// 判断进程是否在运行(通过进程名称)
/// </summary>
/// <param name="exe_name">不要扩展名,例如:abc.exe,此处应填写abc</param>
/// <returns></returns>
internal static bool IsRun(string exe_name)
{
try
Expand All @@ -308,11 +246,6 @@ internal static bool IsRun(string exe_name)
}
}

/// <summary>
/// 判断进程是否在运行(通过进程ID号)
/// </summary>
/// <param name="exe_id">进程ID号</param>
/// <returns></returns>
internal static bool IsRun(int exe_id)
{
try
Expand All @@ -334,12 +267,6 @@ internal static bool IsRun(int exe_id)
}
}

/// <summary>
/// 通过进程窗口标题,获取符合条件的进程对象列表
/// </summary>
/// <param name="window_title"></param>
/// <param name="need_equal">如果为true,则需要标题严格与预期值相等。反之,窗口标题只需包含预期值即可。默认为 false。</param>
/// <returns></returns>
internal static List<Process> GetProcessByTitle(string window_title, bool need_equal = false)
{
try
Expand Down
Loading

0 comments on commit 31b542b

Please sign in to comment.