CreateThread function kernel32

Win32Result<HANDLE> CreateThread(
  1. Pointer<SECURITY_ATTRIBUTES>? lpThreadAttributes,
  2. int dwStackSize,
  3. Pointer<NativeFunction<LPTHREAD_START_ROUTINE>> lpStartAddress,
  4. Pointer<NativeType>? lpParameter,
  5. THREAD_CREATION_FLAGS dwCreationFlags,
  6. Pointer<Uint32>? lpThreadId,
)

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

To learn more, see learn.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-createthread.

Implementation

Win32Result<HANDLE> CreateThread(
  Pointer<SECURITY_ATTRIBUTES>? lpThreadAttributes,
  int dwStackSize,
  Pointer<NativeFunction<LPTHREAD_START_ROUTINE>> lpStartAddress,
  Pointer? lpParameter,
  THREAD_CREATION_FLAGS dwCreationFlags,
  Pointer<Uint32>? lpThreadId,
) {
  final result_ = CreateThread_Wrapper(
    lpThreadAttributes ?? nullptr,
    dwStackSize,
    lpStartAddress,
    lpParameter ?? nullptr,
    dwCreationFlags,
    lpThreadId ?? nullptr,
  );
  return Win32Result(value: HANDLE(result_.value.ptr), error: result_.error);
}