File Handling
This section provides reference documentation for APIs related to file input and output operations on Windows. Understanding these APIs is crucial for managing data persistence, configuring applications, and interacting with the file system.
Core File Operations
These functions are fundamental for creating, opening, reading, writing, and closing files.
| Function | Description |
|---|---|
CreateFile |
Creates or opens a file or I/O device. It is the primary function for obtaining a file handle. |
ReadFile |
Reads data from a file or from the communication parameters of a serial communications device. |
WriteFile |
Writes data to a file or to the communications parameters of a serial communications device. |
CloseHandle |
Closes an open object handle. |
SetFilePointer |
Moves the file pointer (pointer that tracks where data will be read or written) in the specified file. |
GetFileSizeEx |
Retrieves the size of the specified file. |
File Attributes and Metadata
Manage file properties such as attributes, timestamps, and security information.
| Function | Description |
|---|---|
SetFileAttributes |
Sets the attributes for a file. |
GetFileAttributesEx |
Retrieves extended attributes for a specified file or directory. |
SetFileTime |
Sets the creation, access, and last write times for a file. |
GetFileTime |
Retrieves the creation, last access, and last write times for a file. |
DeviceIoControl |
Performs a specified control operation on a device. Can be used for advanced file system operations. |
Advanced File Operations
Includes features like file locking, asynchronous I/O, and memory-mapped files.
| Function | Description |
|---|---|
LockFile |
Adds or removes an advisory lock on a specified byte range in a file. |
CreateIoCompletionPort |
Creates a new I/O completion port or opens an existing one. Essential for asynchronous I/O. |
CreateFileMapping |
Creates or opens a named or unnamed file mapping object. |
MapViewOfFile |
Maps a view of a file mapping into the address space of the calling process. |
UnmapViewOfFile |
Unmaps a mapped view of a file from the calling process's address space. |
Related Concepts
For comprehensive details on each function, including parameters, return values, and code examples, please refer to the individual function documentation links.