mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-06 14:34:05 +02:00
Add WindowsUtils.IsChildProcess to check process parent
This commit is contained in:
parent
4818652582
commit
fb94bf1b80
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Management;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
@ -77,6 +78,20 @@ public static void TryDeleteFolderWhenAble(string path, int timeout){
|
||||
}).Start();
|
||||
}
|
||||
|
||||
public static bool IsChildProcess(int pid){
|
||||
try{
|
||||
using(ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT ParentProcessId FROM Win32_Process WHERE ProcessId = "+pid)){
|
||||
foreach(ManagementBaseObject obj in searcher.Get()){
|
||||
return (uint)obj["ParentProcessId"] == CurrentProcessID;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}catch{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClipboardStripHtmlStyles(){
|
||||
if (!Clipboard.ContainsText(TextDataFormat.Html)){
|
||||
return;
|
||||
|
@ -65,6 +65,7 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user