For an example here:
|
// Open handle to the target process |
|
IntPtr ProcHandle = OpenProcess( |
|
ProcessAccessFlags.All, |
|
false, |
|
ProcId); |
|
if (ProcHandle == null) |
|
{ |
|
Console.ForegroundColor = ConsoleColor.Red; |
|
Console.WriteLine("[!] Handle to target process could not be obtained!"); |
|
Console.ForegroundColor = ConsoleColor.White; |
|
System.Environment.Exit(1); |
|
} |
The result will never be null, but it could be of type IntPtr.Zero, which is what you are trying to check.