Windows API Reference
Welcome to the comprehensive reference for the Windows API. This section provides detailed information on the functions, structures, constants, and concepts necessary for developing applications on the Windows platform.
Introduction to the Windows API
The Windows API (Application Programming Interface) is a set of definitions and protocols that allows software components to communicate with each other. It enables developers to harness the full power of the Windows operating system, providing access to its features and functionalities.
This reference is organized into logical sections, covering various aspects of Windows development, from core system services to advanced graphics and networking capabilities.
Core APIs
Explore the fundamental building blocks of Windows programming.
Kernel Services
Functions related to memory management, process and thread manipulation, synchronization, and I/O operations.
Creates a new process and its primary thread. The new process runs in the same address space of the calling process.
LPWSTR lpApplicationName- The name of the module to be executed.
LPWSTR lpCommandLine- The command line of the process to be executed.
LPSECURITY_ATTRIBUTES lpProcessAttributes- A pointer to a SECURITY_ATTRIBUTES structure that specifies the security attributes of the process object.
LPSECURITY_ATTRIBUTES lpThreadAttributes- A pointer to a SECURITY_ATTRIBUTES structure that specifies the security attributes of the primary thread.
BOOL bInheritHandles- Specifies whether the new process inherits the calling process's environment variables.
DWORD dwCreationFlags- Flags that control the priority class and the way the application is created.
LPVOID lpEnvironment- A pointer to a block of memory that contains a new environment for the child process.
LPCWSTR lpCurrentDirectory- The full path to the current directory for the new process.
LPSTARTUPINFOW lpStartupInfo- A pointer to a STARTUPINFO structure that specifies the window station, standard handles, and appearance of the main window for the new process.
LPPROCESS_INFORMATION lpProcessInformation- A pointer to a PROCESS_INFORMATION structure that receives identification information about the new process and its primary thread.
Example Usage
STARTUPINFOW si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
// Start the child process.
if (CreateProcessW(L"C:\\Windows\\System32\\notepad.exe", // Module name
NULL, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // Default creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi) // Pointer to PROCESS_INFORMATION structure
) {
// Wait until child process exits.
WaitForSingleObject(pi.hProcess, INFINITE);
// Close process and thread handles.
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
} else {
// Handle error
}
Reserves, commits, or changes the state of a region of pages in the virtual address space of the calling process.
Registry Functions
Access and manage the Windows Registry.
Opens an existing key in the registry.
File System Functions
Operations for interacting with files and directories.
Creates or opens a handle to a specified file or device.
Graphics APIs
Tools and interfaces for creating visually rich applications.
GDI (Graphics Device Interface)
The traditional Windows graphics subsystem.
Creates a memory device context (DC) that is compatible with the specified device.
DirectX
A collection of APIs for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms.
Creates a Direct3D 11 device and its associated immediate context.
Networking APIs
Enable network communication for your applications.
Winsock (Windows Sockets API)
The standard API for network programming on Windows.
Creates a socket that is bound to a specific transport service provider.
Establishes a connection to a specified remote application.
Security APIs
APIs for managing security and access control.
Enables a server thread to impersonate a client on whose behalf the server thread is running.
COM and Interop
Component Object Model and interoperability features.
Initializes the COM library on the current thread and specifies concurrency model.
Error Handling
Understanding and responding to API errors.
Most Windows API functions return a value that indicates success or failure. On failure, you can typically use GetLastError() to retrieve a specific error code.
Retrieves the last error code set by a function in the current thread.
Common Data Types
Familiarize yourself with the fundamental data types used throughout the Windows API.
A 32-bit unsigned integer.
A pointer to a null-terminated wide character string.
A boolean value, typically represented as 0 for FALSE and non-zero for TRUE.