_lcreat

  HFILE _lcreat(lpszFileName, fnAttribute)    
  LPCSTR lpszFileName; /* points to file to open */
  int fnAttribute; /* file attributes */

The _lcreat function creates or opens a specified file. If the file does not exist, the function creates a new file and opens it for writing. If the file does exist, the function truncates the file size to zero and opens it for reading and writing. When the function opens the file, the pointer is set to the beginning of the file.

Parameters

lpszFileName

Points to a null-terminated string that names the file to be opened. The string must consist of characters from the Windows character set.

fnAttribute

Specifies the file attributes. The parameter must be one of the following values:

Value Meaning

0  
  Normal; can be read or written without restriction.
1  
  Read-only; cannot be opened for write.
2  
  Hidden; not found by directory search.
3  
  System; not found by directory search.

Return Value

The return value is a file handle if the function is successful. Otherwise, it is HFILE_ERROR.

Comments

Use this function carefully. It is possible to open any file, even one that has already been opened by another function.

This function is maintained for compatibility with previous versions of Windows. Win32 applications should use the CreateFile function to create or open a file.

See Also

_lopen, CreateFile