MCPcopy Create free account
hub / github.com/Squirrel/Squirrel.Windows / GetParentProcessId

Method GetParentProcessId

src/Squirrel/NativeMethods.cs:13–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11 public static class NativeMethods
12 {
13 public static int GetParentProcessId()
14 {
15 var pbi = new PROCESS_BASIC_INFORMATION();
16
17 //Get a handle to our own process
18 IntPtr hProc = OpenProcess((ProcessAccess)0x001F0FFF, false, Process.GetCurrentProcess().Id);
19
20 try {
21 int sizeInfoReturned;
22 int queryStatus = NtQueryInformationProcess(hProc, (PROCESSINFOCLASS)0, ref pbi, pbi.Size, out sizeInfoReturned);
23 } finally {
24 if (!hProc.Equals(IntPtr.Zero)) {
25 //Close handle and free allocated memory
26 CloseHandle(hProc);
27 hProc = IntPtr.Zero;
28 }
29 }
30
31 return (int)pbi.InheritedFromUniqueProcessId;
32 }
33
34
35 [DllImport("version.dll", SetLastError = true)]

Callers 1

waitForParentToExitMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected