Handle handle;
Handle = createfile ("F: \ .htm", generic_write, 0, null, create_always, file_attribute_normal, null );
If (invalid_handle_value! = Handle)
{
DWORD num;
: Writefile (handle, text, strlen (text), & num, null );
: Closehandle (handle );
: Closehandle (handle );
}
Text is a string variable. Note that it contains HTML tags.
Parameters of the createfile function are described as follows:
The name of the file to be opened or created by the first parameter.
Operation attribute of the second parameter in three cases 0: indicates that only information related to one device can be obtained; generic_read: indicates that read access to the device is allowed generic_write: indicates that write access to the device is allowed. note that three cases can be combined.
The third parameter is shared in three cases. 0 indicates that the file is not shared; file_share_read indicates that the file is allowed to be read. file_share_write: Write shared access.
The fourth parameter security feature.
If the Fifth parameter is used for five operations, create_new: Creates a file. If the file exists, create_always: Creates the file. The previous file open_existing: the file must already exist. Required by the device open_always: create a file if the file does not exist; truncate_existing: shorten the existing file to zero length.
In 12 cases of the sixth parameter attribute, file_attribute_archive: Mark the archive attribute; file_attribute_compressed: Mark the file as compressed, or mark it as the default compression method of the file in the directory; file_attribute_normal: Default attribute: hide a file or directory; file_attribute_readonly: The file is read-only; file_attribute_system: The file is a system file; file_flag_write_through: the operating system must not postpone file write operations; file_flag_overlapped: Allows overlapping operations on; file_flag_no_buffering: file buffering is prohibited. The file can only be written into the sector block of the disk volume; file_flag_random_access: optimizes the File Buffer for random access; file_flag_sequential_scan: optimizes the File Buffer for continuous access; ile_flag_delete_on_close: after closing the last opened handle, delete the file. It is especially suitable for temporary files.
If the seventh parameter is not zero, a file handle is specified. The new file will copy the extended attributes from this file.
Writefile writes data to the created or opened file.
The num variable gets the length of the total Written string.