共用方式為


_FCopy( ) API Library Routine

Attempts to copy len bytes from the offset position spos in source file sc to the offset position dpos in destination file dc.

int _FCopy(FCHAN dc, long dpos, FCHAN sc, long spos, long len)
FCHAN dc;                  /* File channel of destination file. */
long dpos;                  /* Offset position to start copying to. */
FCHAN sc;                  /* File channel of source file. */
long spos;                  /* Offset position to start copying from. */
long len;                     /* Number of bytes to copy. */

Remarks

_FCopy( ) returns True (an integer other than 0) if it succeeds, or False (0) if it fails.

For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.

Example

The following example creates two files. It writes the text "Hello, world" to the first of these files and then copies the contents of this file, beginning with the third byte, to the second file.

Visual FoxPro Code

SET LIBRARY TO FCOPY 

C Code

#include <pro_ext.h>

FAR Example(ParamBlk FAR *parm)
{
   FCHAN fchan1, fchan2;
   int len;

   fchan1 = _FCreate("temp1.txt", FC_NORMAL);
   _FPuts(fchan1, "Hello, world.");
   _FFlush(fchan1);

   len = _FSeek(fchan1, 0, FS_FROMEOF); // determine length of file

   fchan2 = _FCreate("temp2.txt", FC_NORMAL);
   _FCopy(fchan2, 0, fchan1, 2, len - 2);

   _FClose(fchan1);
   _FClose(fchan2);
}

FoxInfo myFoxInfo[] = {
   {"FCOPY", (FPFI) Example, CALLONLOAD, ""},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

_FPuts( ) API Library Routine | _FWrite( ) API Library Routine | _FCreate( ) API Library Routine | Accessing the Visual FoxPro API