Kernel32CreateThread(IntPtr, IntPtr, ThreadStart, IntPtr, CreateThreadFlags, UInt32) Method

Creates a thread to execute within the virtual address space of the calling process.

To create a thread that runs in the virtual address space of another process, use the CreateRemoteThread(IntPtr, SecurityAttributes, IntPtr, IntPtr, IntPtr, CreateThreadFlags, UInt32) function.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static IntPtr CreateThread(
	IntPtr threadAttributes,
	IntPtr stackSize,
	ThreadStart startAddress,
	IntPtr threadParameter,
	CreateThreadFlags creationFlags,
	ref uint refThreadId
)

Parameters

threadAttributes  IntPtr
A pointer to a SecurityAttributes structure that determines whether the returned handle can be inherited by child processes.

If threadAttributes is Zero, the handle cannot be inherited.

The SecurityDescriptor member of the structure specifies a security descriptor for the new thread.

If threadAttributes is Zero, the thread gets a default security descriptor. The ACLs in the default security descriptor for a thread come from the primary token of the creator.

stackSize  IntPtr
The initial size of the stack, in bytes. The system rounds this value to the nearest page.

If this parameter is zero, the new thread uses the default size for the executable.

startAddress  ThreadStart
A pointer to the application-defined function to be executed by the thread.

This pointer represents the starting address of the thread.

threadParameter  IntPtr
A pointer to a variable to be passed to the thread.
creationFlags  CreateThreadFlags
The flags that control the creation of the thread.
refThreadId  UInt32
A pointer to a variable that receives the thread identifier.

If this parameter is , the thread identifier is not returned.

Return Value

IntPtr
If the function succeeds, the return value is a handle to the new thread.

If the function fails, the return value is Zero.

To get extended error information, call GetLastWin32Error.

Remarks

See Also