Creates a thread that executes within the address space of the calling process.
/* sample declaration of thread start */
DWORD WINAPI ThreadProc(
LPVOID lpParameter
);
HANDLE CreateThread(
LPSECURITY_ATTRIBUTES lpThreadAttributes,
DWORD dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddress,
LPVOID lpParameter,
DWORD dwCreationFlags,
LPDWORD lpThreadId
);
Parameters
lpThreadAttributes
- Ignored; set to NULL.
dwStackSize
- Number of bytes to allocate to the new thread's stack.
lpStartAddress
- Pointer to the application-defined function of type LPTHREAD_START_ROUTINE, executed by the thread. Represents the thread's starting address, which must be of the form:
DWORD WINAPI ThreadProc (
LPVOID lpParameter
);
Note: Do not set lpStartAddr
to NULL. Passing this value in the parameter causes the function to return ERROR_INVALID_PARAMETER.
lpParameter
- Pointer passed to the thread.
dwCreationFlags
- Specifies flags that control the thread's creation. Valid values include:
- CREATE_SUSPENDED
- The thread is created in a suspended state and does not run until ResumeThread is called.
If the flag is not specified, the thread starts immediately after creation.
lpThreadId
- Pointer to a 32-bit variable that receives the thread identifier. If this parameter is NULL, the thread identifier does not return.
Remarks
- In
dwCreationFlags
only the CREATE_SUSPENDED flags is recognized.
dwStackSize
is adjusted up to a multiple of 4K bytes.
- The thread is created with INtime priority 253, which corresponds to iwin32 priority -15 and RTX priority 0.
- Thread execution begins at the function specified by the
lpStartAddress
parameter. If this function returns, the DWORD return value terminates the thread in an implicit call to ExitThread. To get the thread's return value, use GetExitCodeThread.
- The thread is created with a thread priority of THREAD_PRIORITY_NORMAL. To get and set a thread's priority value, use GetThreadPriority and SetThreadPriority.
- When a thread terminates, the thread object attains a signaled state, satisfying threads waiting on the object. The thread object remains in the system until the thread terminates and all handles to it close through a call to CloseHandle.
Return Values
- Handle to new thread
- Success.
- NULL
- Failure. For extended error information, see GetLastError.
Requirements
Versions |
Defined in |
Include |
Link to |
INtime 3.0 |
intime/rt/include/winbase.h |
windows.h |
iwin32.lib |
See Also