GetCurrentThread (kernel32)
Last changed: 24.246.166.222

.
Summary

C# Signature:

[DllImport("kernel32.dll")]
static extern IntPtr GetCurrentThread();

User-Defined Types:

None.

Notes:

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.

Tips & Tricks:

Please add some!

Sample Code:

IntPtr currThread = GetCurrentThread();

Alternative Managed API:

idThead = Process.GetCurrentProcess().Threads[0].Id;

Documentation