CreateFile PROC   (MS-Windows)

   Creates or opens files and other objects and returns a handle to be used to access the object.
   Use CloseHandle to close the object.
   Call GetLastError to get extended error information.


CreateFile PROTO,           ; create new file
    pFilename:PTR BYTE,     ; ptr to filename
    accessMode:DWORD,       ; access mode
    shareMode:DWORD,        ; share mode
    lpSecurity:DWORD,       ; can be NULL
    howToCreate:DWORD,      ; how to create the file
    attributes:DWORD,       ; file attributes
    htemplate:DWORD         ; handle to template file

Returns: (HANDLE) EAX = Handle if successful,
                        INVALID_HANDLE_VALUE if fails.
Argument Win Type MASM Type Description
pFilename LPCTSTR PTR BYTE  Pointer to the name of the file.
accessMode DWORD DWORD  Access (read-write) mode.
· Zero - an application can query device attributes without accessing the device.
· GENERIC_READ
· GENERIC_WRITE
· GENERIC_READ may be combined with GENERIC_WRITE for read-write access.
shareMode DWORD DWORD  Share mode.
lpSecurity LPSECURITY_ATTRIBUTES DWORD  Pointer to security attributes.
 If NULL, the handle cannot be inherited.
howToCreate DWORD DWORD  How to create the file.
· CREATE_NEW - Creates a new file, fails if file already exists.
· CREATE_ALWAYS - Creates a new file, if file exists, it is overwritten and the existing attributes are cleared.
· OPEN_EXISTING - Opens the file, fails if file does not exist.
· OPEN_ALWAYS - opens existing file, else creates and opens a new file.
· TRUNCATE_EXISTING - opens file, sets file size to zero, fails if the file does not exist. File must have GENERIC_WRITE access.
attributes DWORD DWORD  File attributes.
· FILE_ATTRIBUTE_ARCHIVE - The file should be archived. Applications use this attribute to mark files for backup or removal.
· FILE_ATTRIBUTE_HIDDEN - The file is hidden. It is not to be included in an ordinary directory listing.
· FILE_ATTRIBUTE_NORMAL - The file has no attributes set. This attribute is valid only when used alone.
· FILE_ATTRIBUTE_READONLY - The file is read only. Applications can read the file but cannot write or delete it.
· FILE_ATTRIBUTE_TEMPORARY - The file is being used for temporary storage.
htemplate HANDLE DWORD  Handle to a file with attributes to copy.

Converted from CHM to HTML with chm2web Pro 2.85 (unicode)