The CreateFile
function initiates a file access operation. It opens a file for reading, writing, appending, or random access. It also allows the user to set access rights, the file sharing mode, and other file attributes.
BOOL CreateFile(
LPCTSTR lpFileName, // Pointer to the name of the file to open.
DWORD dwOpenMode, // Specifies the type of access.
DWORD dwAccessRights, // Specifies the access rights.
LPSECURITY_ATTRIBUTES lpSecurityAttributes, // Pointer to a SECURITY_ATTRIBUTES structure.
DWORD dwShareMode, // Specifies the file sharing mode.
DWORD dwFileAttributeFlags, // Specifies file attribute flags.
HANDLE hTemplateFile // Handle to a template file.
);
Access Modes:
FILE_GENERIC_READ
FILE_GENERIC_WRITE
FILE_GENERIC_READ | FILE_GENERIC_WRITE
FILE_APPEND
FILE_WRITE_Once