FileSystem API Reference - Windows

This section provides a comprehensive reference for the File API, which allows applications to interact with the Windows file system.

Function Description Parameters Return Value Example
CreateFileW Creates a new file or opens an existing file for access.
  • lpFileName: The name of the file.
  • dwFlagsAndAttributes: Flags indicating how the file should be opened.
  • lpExistingFile: A pointer to an existing file if opening an existing file.
  • lpSecurityAttributes: A pointer to a security attributes structure.
A handle to the file object if successful, or 0 if unsuccessful.
                            
                            HANDLE hFile = CreateFileW(
                                L"C:\\myfile.txt",
                                GENERIC_READ | GENERIC_WRITE,
                                FILE_SHARE_READ,
                                NULL,
                                OPEN_ALWAYS,
                                FILE_ATTRIBUTE_NORMAL,
                                NULL
                            );
                            
                        
GetFileInfoA Retrieves information about a file.
  • lpFileName: The name of the file.
  • lpFindFileData: A pointer to a FindFileData structure to be filled with the file information.
TRUE if successful, FALSE if an error occurred.
                            
                            BOOL bResult = GetFileInfoA(
                                L"C:\\myfile.txt",
                                (FindFileData)malloc(sizeof(FindFileData))
                            );