Click or drag to resize

FOpen2 Function

X#
Open a file, specifying two strongly-typed arguments.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.19
Syntax
 FUNCTION FOpen2(
	cFileName AS STRING,
	kMode AS DWORD
) AS IntPtr
Request Example View Source

Parameters

cFileName
Type: String
The file name, including an optional drive, directory, and extension. SetDefault() and SetPath() settings are ignored; the Windows default is used unless you specify a drive and directory as part of the file name. No extension is assumed.
This function sets NetErr() in case of a concurrency control conflict.
kMode
Type: DWord
This argument is the same as kMode used with FOpen(). See FOpen() for details.

Return Value

Type: IntPtr
The file handle of the opened file in the range of 0 to 32,767.
If an error occurs, FOpen2() returns F_ERROR. FError() can be used to determine the specific error.
Remarks
Note that in order for two processes to use the same file simultaneously, both files should be opened in FO_SHARED sharing mode.
Examples
This example uses FOpen2() to open a file with sharable read/write status and displays an error message if the open fails:
X#
1ptrHandle := FOpen2("temp.txt",;
2    FO_READWRITE + FO_SHARED)
3IF ptrHandle = F_ERROR
4    ? DOSErrString(FError())
5ENDIF
See Also