While working with WinAPI, I decided to implement a call to GetProcessAfinityMask in my C# application. However, I've seen two different signatures for this function.
One of them uses SafeProcessHandle
for the handle:
[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern bool GetProcessAffinityMask(SafeProcessHandle handle, out IntPtr processMask, out IntPtr systemMask);
The other possible version (on P/Invoke) uses IntPtr
:
[DllImport("kernel32.dll",SetLastError = true)]
static extern bool GetProcessAffinityMask(IntPtr hProcess,
out UIntPtr lpProcessAffinityMask, out UIntPtr lpSystemAffinityMask);
Given that both functions return the same values, what is the difference between passing a SafeProcessHandle
instance or IntPtr
?