Process Threads API

Overview

The Process Threads API provides functions for creating, managing, and synchronizing processes and threads on Windows platforms. It includes utilities for process creation, termination, priority control, and thread handling.

Functions

CreateProcess
BOOL CreateProcess( LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation );
Creates a new process and its primary thread. Used for launching executables with detailed control over security, environment, and window settings.
OpenProcess
HANDLE OpenProcess( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId );
Retrieves a handle to an existing process. The handle can be used for various operations such as termination, synchronization, or memory manipulation.
TerminateProcess
BOOL TerminateProcess( HANDLE hProcess, UINT uExitCode );
Forces the termination of a process. Use with caution as it does not allow for graceful cleanup.
CreateThread
HANDLE CreateThread( LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId );
Creates a new thread within the calling process. Provides low‑level control over stack size and creation flags.
ExitThread
VOID ExitThread( DWORD dwExitCode );
Ends the calling thread and returns an exit code to any waiting thread.
Sleep
VOID Sleep( DWORD dwMilliseconds );
Suspends the execution of the current thread for the specified interval.
WaitForSingleObject
DWORD WaitForSingleObject( HANDLE hHandle, DWORD dwMilliseconds );
Waits until the specified object is in the signaled state or the time-out interval elapses.
GetCurrentProcessId
DWORD GetCurrentProcessId(void);
Retrieves the process identifier of the calling process.
GetCurrentThreadId
DWORD GetCurrentThreadId(void);
Retrieves the thread identifier of the calling thread.