An application-defined function that serves as the starting address for a thread. Specify this address when calling the
CreateThread or
CreateRemoteThread function.
The LPTHREAD_START_ROUTINE type defines a pointer to this callback function.
ThreadProc is a placeholder for the application-defined function name.
Syntax
DWORD WINAPI ThreadProc(
__in LPVOID lpParameter
);
Parameters
- lpParameter [in]
-
The thread data passed to the function using the lpParameter parameter of the
CreateThread or
CreateRemoteThread function.
Return Value
The return value indicates the success or failure of this function.
Do not declare this callback function with a void return type and cast the function pointer to LPTHREAD_START_ROUTINE when creating the thread. Code that does this is common, but it can crash on 64-bit Windows.
Remarks
A process can determine when a thread it created has completed by using one of the wait functions. It can also obtain the return value of its
ThreadProc by calling the
GetExitCodeThread function.
Each thread receives a unique copy of the local variables of this function. Any static or global variables are shared by all threads in the process. To provide unique data to each thread using a global index, use thread local storage.
Examples
For an example, see
Creating Threads.
Requirements
| Client | Requires Windows Vista, Windows XP, or Windows 2000 Professional. |
| Server | Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server. |
| Header | Declared in Winbase.h; include Windows.h. |
See Also
CreateThread
CreateRemoteThread
GetExitCodeThread
Send comments about this topic to Microsoft
Build date: 8/7/2008