Windows API Reference

Explore the core functions and capabilities of the Windows operating system. This reference provides detailed information on APIs used for system interactions, process management, file operations, and more.

Core Functions

Fundamental APIs for interacting with the Windows environment.

File System Operations

APIs for managing files and directories.

WriteFile

Writes data to a specified file or input/output (I/O) device.

Parameters:
  • HANDLE hFile: A handle to the file or device to be written to.
  • LPCVOID lpBuffer: A pointer to a buffer that contains the data to be written to the file or device.
  • DWORD nNumberOfBytesToWrite: The number of bytes to be written from the buffer to the file or device.
  • LPDWORD lpNumberOfBytesWritten: A pointer to a variable that receives the number of bytes written by this function.
  • LPOVERLAPPED lpOverlapped: A pointer to a OVERLAPPED structure or NULL.
Return Value:

If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. For extended error information, call GetLastError.

ReadFile

Reads data from a specified file or input/output (I/O) device.

Parameters:
  • HANDLE hFile: A handle to the file or device to be read from.
  • LPVOID lpBuffer: A pointer to a buffer that receives the contents of the file or device.
  • DWORD nNumberOfBytesToRead: The maximum number of bytes to be read.
  • LPDWORD lpNumberOfBytesRead: A pointer to a variable that receives the number of bytes read.
  • LPOVERLAPPED lpOverlapped: A pointer to an OVERLAPPED structure or NULL.
Return Value:

If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. For extended error information, call GetLastError.

Registry Operations

APIs for accessing and manipulating the Windows Registry.

RegOpenKeyEx

Opens an existing key in the registry. If the key or subkey does not exist, the function does not create it.

Parameters:
  • HKEY hKey: A handle to an open key by calling the RegCreateKeyEx or RegOpenKeyEx function.
  • LPCTSTR lpSubKey: The name of the registry subkey to be opened.
  • DWORD ulOptions: Reserved for future use. Must be zero.
  • REGSAM samDesired: An access mask that specifies the security access desired for the key.
  • PHKEY phkResult: A pointer to a variable that receives a handle to the opened key.
Return Value:

If the function succeeds, the return value is ERROR_SUCCESS. If the function fails, the return value is a system error code.

Processes and Threads

APIs for managing processes and threads.

CreateProcess

Creates a new process and its primary thread. The new process runs in the security context of the calling process.

Parameters:
  • LPCTSTR lpApplicationName: The name of the module to be executed.
  • LPTSTR lpCommandLine: The command line for the process to be executed.
  • LPSECURITY_ATTRIBUTES lpProcessAttributes: A pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by the child process.
  • LPSECURITY_ATTRIBUTES lpThreadAttributes: A pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by the child process.
  • BOOL bInheritHandles: If this parameter is TRUE, each inheritable handle in the calling process is duplicated in the new process.
  • DWORD dwCreationFlags: Flags that control the priority class and behavior of the new process.
  • LPVOID lpEnvironment: A pointer to a null-terminated list of null-terminated strings, preceded by a null character and terminated by a second null character.
  • LPCTSTR lpCurrentDirectory: The full path to the current directory for the new process.
  • LPSTARTUPINFO lpStartupInfo: A pointer to a STARTUPINFO structure that specifies the window station, startup info, heap information, and standard handles for the new process.
  • LPPROCESS_INFORMATION lpProcessInformation: A pointer to a PROCESS_INFORMATION structure that receives identification information about the new process.
Return Value:

If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.

GetCurrentProcess

Returns a pseudo handle for the current process. A pseudo handle is a special constant that is equivalent to the actual handle of the process.

Parameters:

None.

Return Value:

The return value is a pseudo handle to the current process. This handle cannot be used to identify the process in most functions; to do this, call the OpenProcess function.

Networking

APIs for network communication.