This document outlines key functions and concepts for interacting with the file system in the Windows API (Win32).
Creates or opens a file or I/O device. It is the primary function for accessing files.
lpFileName: The name of the file to be created or opened.dwDesiredAccess: The type of access to the file (e.g., GENERIC_READ, GENERIC_WRITE).dwShareMode: How the file will be shared.lpSecurityAttributes: Security descriptor.dwCreationDisposition: Action to take if the file exists or does not exist.dwFlagsAndAttributes: File attributes and flags.hTemplateFile: Handle to a template file.INVALID_HANDLE_VALUE.Reads data from a file or from the communication port specified by a handle.
hFile: Handle to the file to be read.lpBuffer: Pointer to the buffer that receives the data read from the file.nNumberOfBytesToRead: The maximum number of bytes to be read.lpNumberOfBytesRead: Pointer to the number of bytes read.lpOverlapped: Pointer to an OVERLAPPED structure.TRUE if the function succeeds or the function completes asynchronously.FALSE if the function fails.Writes data to a file or to the communication port specified by a handle.
hFile: Handle to the file to be written to.lpBuffer: Pointer to a buffer containing the data to be written.nNumberOfBytesToWrite: The number of bytes to write.lpNumberOfBytesWritten: Pointer to the number of bytes written.lpOverlapped: Pointer to an OVERLAPPED structure.TRUE if the function succeeds or the function completes asynchronously.FALSE if the function fails.Closes an open object handle. Applications must call this function for every handle that it opens.
hObject: A handle to an open object.TRUE if the function succeeds.FALSE if the function fails.Creates a new directory with the specified path.
lpPathName: The path of the directory to create.lpAttribute: Security attributes.TRUE if the directory is created successfully.FALSE if the directory creation fails.Deletes an existing empty directory.
lpPathName: Path of the directory to be removed.TRUE if the directory is removed successfully.FALSE if the directory removal fails (e.g., directory not empty).Retrieves the attributes of a specified file or directory.
lpFileName: The name of the file or directory.INVALID_FILE_ATTRIBUTES.FILE_ATTRIBUTE_NORMALFILE_ATTRIBUTE_READONLYFILE_ATTRIBUTE_HIDDENFILE_ATTRIBUTE_DIRECTORYFILE_ATTRIBUTE_ARCHIVESets the attributes of a specified file or directory.
lpszFileName: The name of the file or directory.dwFileAttributes: The new file attributes.TRUE if the function succeeds.FALSE if the function fails.