[Solved] WINDOWS API: GetCurrentThread(); in C [closed]


Operating systems courses tend to suck because they take the simplest of concepts and try to make them convoluted.

Documentation for the GetCurrentThread () function is

https://learn.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-getcurrentthread

What it does not explain is that the return value for the function is a “handle.” Windoze uses handles somewhat as pointers to objects but where you cannot access the object directly.

So you call GetCurrent() thread and it returns a “Handle to the Thread.” That handle can then be used to do things with the thread.

Here are the things you can do:

https://learn.microsoft.com/en-us/windows/desktop/ProcThread/process-and-thread-functions

Some of these function pages have short examples.

So you could do:

print ("Thread ID: %d\n", GetThreadID (GetCurrentThread())) ;

and have the ID of the current thread.

solved WINDOWS API: GetCurrentThread(); in C [closed]