Skip to content

Latest commit

 

History

History
82 lines (62 loc) · 3.15 KB

CreateFile.md

File metadata and controls

82 lines (62 loc) · 3.15 KB

Home

Function name : CreateFile

Group: File Management - Library: kernel32


This function creates, opens, or truncates a file, communications resource, disk device, or console. It returns a handle that can be used to access the object. It can also open and return a handle to a directory.

Use the CloseHandle function to close an object handle returned by CreateFile


Code examples:

Using the CreateFile
Using the DeleteFile
Creating a file, then moving it to another destination
Obtaining physical parameters for a drive: sectors, clusters, cylinders...
HOWTO: Use the Win32 API to Access File Dates and Times
Storing screen shot of a form to bitmap file
Storing content of the Clipboard to a bitmap file
Using InternetSetFilePointer when resuming interrupted download from the Internet
Using mailslots to send messages on the network
Testing serial ports
Subclassing CommandButton control to create BackColor property
Vertical Label control
How to set Creation Date/Time for a folder (WinNT)
Monitoring changes occurring within a directory
Peer-to-peer LAN messenger built with Mailslot API functions
How to convert a bitmap file to monochrome format (1 bpp)
Using named pipes for interprocess communication

Declaration:

HANDLE CreateFile(
	LPCTSTR lpFileName,
	DWORD dwDesiredAccess,
	DWORD dwShareMode,
	LPSECURITY_ATTRIBUTES lpSecurityAttributes,
	DWORD dwCreationDispostion,
	DWORD dwFlagsAndAttributes,
	HANDLE hTemplateFile);  

FoxPro declaration:

DECLARE INTEGER CreateFile IN kernel32;
	STRING  lpFileName,;
	INTEGER dwDesiredAccess,;
	INTEGER dwShareMode,;
	INTEGER lpSecurityAttributes,;
	INTEGER dwCreationDisposition,;
	INTEGER dwFlagsAndAttributes,;
	INTEGER hTemplateFile  

Parameters:

Skipped


Return value:

An open handle to the specified file indicates success


Comments:

lpSecurityAttributes is ignored for Win9*.

Attribute FILE_FLAG_DELETE_ON_CLOSE -- is handy for creating temporary files. Indicates that the operating system is to delete the file immediately after all of its handles have been closed. So you don"t care to delete this file afterwards. When you do not need it anymore -- just close the handle or exit VFP.

The huge variety of avilable attributes makes this command very strong and sophisticated.
The function also can be used to put a message in a mailslot.

See also: CreateFileTransacted.