CopyFileEx function
The CopyFileEx function copies a file from a source to a destination. The pointers to the path strings are passed through the stack. The function automatically aligns the stack to 4 bytes.
Parameters (stack): 1. Pointer to the name of the source file. 2. Pointer to the destination path.
Return value: On success (CF=0) the file is copied; on error (CF=1) AX contains the error code.
Flag state: The function affects all flags.
Program source code
Intel 8086 assembly program example demonstrating the use of the CopyFileEx function to copy a file from a source to a destination. The paths are passed through the stack.
title .286C .model small .stack 100h data segment public path db "folder\my_file\", 0 fname db "test.txt", 0 data ends code segment public assume ds:data, cs:code include Handyfar.inc ; Include the file with functions include Handymac.inc ; Include the file with macros main proc call SetDataSegment ; Call the SetDataSegment procedure pushs es:[path] ; Push the address of the path variable onto the top of the stack pushs ds:[fname] ; Push the address of the fname variable onto the top of the stack call CopyFileEx ; Call the CopyFileEx(fname, path) procedure := CF push 0 ; Push the byte return code onto the top of the stack call ExitProcessEx ; Call the ExitProcessEx(0) procedure main endp code ends end main
(The function only changes the flags, no output is provided)
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".