This does not return a real handle, but a fixed value which is interpreted as the current, calling thread by any function which requires a thread handle. To get the real handle, you need to call GetCurrentThreadId, then OpenThread with the returned value along with the necessary permissions and what-not. Then close the handle when you're done with it.
3/29/2017 11:55:16 AM - mark at [nospam]epitman.com-12.151.76.126
The OpenThread API
6/27/2020 8:38:47 PM - -186.136.223.176
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.