O'Reilly logo

Programming Windows®, Fifth Edition by Charles Petzold

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required