Windows Multithreading

The API function to create a new thread of execution is named CreateThread. The function has the following syntax:

hThread = CreateThread (&security_attributes, dwStackSize, ThreadProc,
                        pParam, dwFlags, &idThread) ;

The first argument is a pointer to a structure of type SECURITY_ATTRIBUTES. This argument is ignored in Windows 98. It can also be set to NULL in Windows NT. The second argument is an initial stack size for the new thread; this argument can be set to 0 for a default value. In any case, Windows dynamically lengthens the stack, if necessary.

The third argument to CreateThread is a pointer to the thread function. This can have any name but must have the syntax

DWORD WINAPI ThreadProc (PVOID pParam) ;

The fourth argument ...

Get Programming Windows®, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.