Let’s say I keep DWORD thread_Id in some structure (WinAPI) .
(I am asking about thread_ID not thread_handle in this question. Indeed it is easy to confure the two)
I need to initialize threadId variable to some some null value.
So I am going to define my NULL_THREAD_ID value.
Is it documented anywhere on msdn which DWORD value real thread can never have as thread_ID ? 0 or (DWORD)-1 ?
HANDLE WINAPI CreateThread(
__in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes,
__in SIZE_T dwStackSize,
__in LPTHREAD_START_ROUTINE lpStartAddress,
__in_opt LPVOID lpParameter,
__in DWORD dwCreationFlags,
__out_opt LPDWORD lpThreadId
);
GetThreadId, for example, gives you the answer to the puzzle. It returns the thread ID and the documentation states:Therefore, zero can never be a valid thread ID.