Consultor Eletrônico



Kbase 17322: How to Call WIN32 API Function: CopyFile
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
How to Call WIN32 API Function: CopyFile

DISCLAIMER:
===========
The code example in this knowledgebase is for informational purposes
only. If you have specific questions about which API calls would be
best suited to your design goals, please consult your Microsoft
documentation.

INTRODUCTION:
=============
The following sample code shows how to call the Win32 API function
called CopyFile. This function copies a file to a new file. The file
attributes, such as FILE_ATTRIBUTE_READONLY, are copied to the new
file. The security attributes are not copied to the new file.

This code has been tested on Windows NT 4.0 Workstation only.


&SCOPED-DEFINE OVERWRITE_IF_EXISTS 0
&SCOPED-DEFINE FAIL_IF_EXISTS 1

DEFINE VARIABLE intResult AS INTEGER NO-UNDO.

PROCEDURE CopyFileA EXTERNAL "KERNEL32.DLL":
DEFINE INPUT PARAMETER chrSourceFile AS CHARACTER.
DEFINE INPUT PARAMETER chrTargetFile AS CHARACTER.
DEFINE INPUT PARAMETER intFailIfExists AS LONG.
DEFINE RETURN PARAMETER intResult AS LONG.
END PROCEDURE.

RUN CopyFileA ("C:\BRIAN.1", "C:\BRIAN.2", 1, OUTPUT intResult).

IF intResult = 1 THEN
MESSAGE "Copy Worked" VIEW-AS ALERT-BOX.
ELSE
MESSAGE "Copy Failed" VIEW-AS ALERT-BOX.

Progress Software Technical Support Note # 17322