-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add KeepModifiedate + Bette Handle console
Add KeepModifiedate + Bette Handle console
- Loading branch information
zzzprojects
committed
Feb 18, 2018
1 parent
54b169e
commit 22ca927
Showing
17 changed files
with
304 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FindAndReplace.App | ||
{ | ||
public static class ProcessExtensions | ||
{ | ||
//https://stackoverflow.com/questions/394816/how-to-get-parent-process-in-net-in-managed-way | ||
private static string FindIndexedProcessName(int pid) | ||
{ | ||
var processName = Process.GetProcessById(pid).ProcessName; | ||
var processesByName = Process.GetProcessesByName(processName); | ||
string processIndexdName = null; | ||
|
||
for (var index = 0; index < processesByName.Length; index++) | ||
{ | ||
processIndexdName = index == 0 ? processName : processName + "#" + index; | ||
var processId = new PerformanceCounter("Process", "ID Process", processIndexdName); | ||
if ((int)processId.NextValue() == pid) | ||
{ | ||
return processIndexdName; | ||
} | ||
} | ||
|
||
return processIndexdName; | ||
} | ||
|
||
private static Process FindPidFromIndexedProcessName(string indexedProcessName) | ||
{ | ||
var parentId = new PerformanceCounter("Process", "Creating Process ID", indexedProcessName); | ||
return Process.GetProcessById((int)parentId.NextValue()); | ||
} | ||
|
||
public static Process Parent(this Process process) | ||
{ | ||
return FindPidFromIndexedProcessName(FindIndexedProcessName(process.Id)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.