-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTools.cs
More file actions
42 lines (37 loc) · 1.37 KB
/
Copy pathTools.cs
File metadata and controls
42 lines (37 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.Diagnostics;
namespace SyncRoomChatToolV2
{
public class Tools
{
/// <summary>
/// 指定された文字列を含むウィンドウタイトルを持つプロセスを取得します。
/// </summary>
/// <param name="windowTitle">ウィンドウタイトルに含む文字列。</param>
/// <returns>該当するプロセスの配列。</returns>
public static Process[] GetProcessesByWindowTitle(string windowTitle)
{
System.Collections.ArrayList list = [];
//すべてのプロセスを列挙する
foreach (Process p in Process.GetProcesses())
{
//指定された文字列がメインウィンドウのタイトルに含まれているか調べる
if (0 <= p.MainWindowTitle.IndexOf(windowTitle))
{
//含まれていたら、コレクションに追加
list.Add(p);
}
}
//コレクションを配列にして返す
return (Process[])list.ToArray(typeof(Process));
}
public static void OpenUrl(string url)
{
ProcessStartInfo pi = new()
{
FileName = url,
UseShellExecute = true,
};
Process.Start(pi);
}
}
}