Attach


The Attach method attaches opened file to the object. Currently attached file is detached, flushing its data buffer and closing it if necessary.
C++
long Attach(
  long FileHandle,                 // file handle
  LPSTR FileName = NULL            // file name
);
BASIC
Attach(
  FileHandle As Long,              // file handle
  Optional FileName As Variant     // file name
) As Long

Parameters

FileHandle
Windows handle referring to opened file.
FileName
C++
Pointer to buffer containing name of the file (must be NULL terminated).
BASIC
Variant containing name of the file.
Variant must be of String data type; it must not be an array.

Return Values

If the method succeeds, the return value is 0.
If the method fails, the return value is failure code and error code is set. Call GetError to get error code.

Remarks

Method is typically used in situations where operation must be performed on file that is already opened. FileHandle must be obtained by either calling Windows system function CreateFile or IXFile method GetFile. File should be opened in access mode compatible with mode of operation of the object in order to read/write operations perform correctly. Optional parameter FileName is not used internally by the object - it is supplied solely for user purposes like error identification.

On completion internal object settings are set to default values. Active buffer is set to its maximum size, read and write counters are reset to zero, data buffers are cleared. File is attached with its current position unchanged.

See Also

Detach, Open, OpenAdvanced, Opening and Attaching File