win32file.CreateFile
PyHANDLE = CreateFile(fileName, desiredAccess , shareMode , attributes , CreationDisposition , flagsAndAttributes , hTemplateFile )
Creates or opens the a file or other object and returns a handle that can be used to access the object.
Parameters
Value | Meaning |
0 | Specifies device query access to the object. An application can query device attributes without accessing the device. |
GENERIC_READ | Specifies read access to the object. Data can be read from the file and the file pointer can be moved. Combine with GENERIC_WRITE for read-write access. |
GENERIC_WRITE | Specifies write access to the object. Data can be written to the file and the file pointer can be moved. Combine with GENERIC_READ for read-write access. |
Value | Meaning |
FILE_SHARE_DELETE | Windows NT: Subsequent open operations on the object will succeed only if delete access is requested. |
FILE_SHARE_READ | Subsequent open operations on the object will succeed only if read access is requested. |
FILE_SHARE_WRITE | Subsequent open operations on the object will succeed only if write access is requested. |
Value | Meaning |
CREATE_NEW | Creates a new file. The function fails if the specified file already exists. |
CREATE_ALWAYS | Creates a new file. If the file exists, the function overwrites the file and clears the existing attributes. |
OPEN_EXISTING | Opens the file. The function fails if the file does not exist. See the Remarks section for a discussion of why you should use the OPEN_EXISTING flag if you are using the CreateFile function for devices, including the console. |
OPEN_ALWAYS | Opens the file, if it exists. If the file does not exist, the function creates the file as if dwCreationDisposition were CREATE_NEW. |
TRUNCATE_EXISTING | Opens the file. Once opened, the file is truncated so that its size is zero bytes. The calling process must open the file with at least GENERIC_WRITE access. The function fails if the file does not exist. |
Comments
The following objects can be opened:files
pipes
mailslots
communications resources
disk devices (Windows NT only)
consoles
directories (open only)