wincerapi.CeCreateFile

PyCEHANDLE = CeCreateFile(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

fileName : PyUnicode

The name of the file

desiredAccess : int

access (read-write) mode Specifies the type of access to the object. An application can obtain read access, write access, read-write access, or device query access. This parameter can be any combination of the following values.

Value Meaning


0Specifies device query access to the object. An application can query device attributes without accessing the device.
GENERIC_READSpecifies 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_WRITESpecifies 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.

shareMode : int

Set of bit flags that specifies how the object can be shared. If dwShareMode is 0, the object cannot be shared. Subsequent open operations on the object will fail, until the handle is closed. To share the object, use a combination of one or more of the following values:

Value Meaning


FILE_SHARE_DELETEWindows NT: Subsequent open operations on the object will succeed only if delete access is requested.
FILE_SHARE_READSubsequent open operations on the object will succeed only if read access is requested.
FILE_SHARE_WRITESubsequent open operations on the object will succeed only if write access is requested.

attributes : PySECURITY_ATTRIBUTES

The security attributes, or None

creationDisposition : int

Specifies which action to take on files that exist, and which action to take when files do not exist. For more information about this parameter, see the Remarks section. This parameter must be one of the following values:

Value Meaning


CREATE_NEWCreates a new file. The function fails if the specified file already exists.
CREATE_ALWAYSCreates a new file. If the file exists, the function overwrites the file and clears the existing attributes.
OPEN_EXISTINGOpens 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_ALWAYSOpens the file, if it exists. If the file does not exist, the function creates the file as if dwCreationDisposition were CREATE_NEW.
TRUNCATE_EXISTINGOpens 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.

flagsAndAttributes : int

file attributes

hTemplateFile : PyHANDLE

Specifies a handle with GENERIC_READ access to a template file. The template file supplies file attributes and extended attributes for the file being created. Under Win95, this must be 0, else an exception will be raised.

Comments

The following objects can be opened:
files
pipes
mailslots
communications resources
disk devices (Windows NT only)
consoles
directories (open only)