Replacement for Free Basic's function FileCopy.
' ========================================================================================
' Copies an existing file to a new file.
' - lpExistingFileName : The name of an existing file.
' To extend the limit of MAX_PATH characters to 32,767 wide characters prepend "\?" to the path.
' If lpExistingFileName does not exist, CopyFile fails, and GetLastError returns ERROR_FILE_NOT_FOUND.
' - lpNewFileName : The name of the new file.
' To extend the limit of MAX_PATH characters to 32,767 wide characters prepend "\?" to the path.
' bFailIfExists
' If this parameter is TRUE and the new file specified by lpNewFileName already exists, the
' function fails. If this parameter is FALSE and the new file already exists, the function
' overwrites the existing file and succeeds.
' If the function succeeds, the return value is nonzero.
' If the function fails, the return value is FALSE. To get extended error information, call GetLastError.
' ========================================================================================
PRIVATE FUNCTION AfxCopyFile (BYVAL lpExistingFileName AS LPCWSTR, BYVAL lpNewFileName AS LPCWSTR, BYVAL bFailIfExists AS BOOLEAN = FALSE) AS BOOLEAN
RETURN CopyFile(lpExistingFileName, lpNewFileName, bFailIfExists)
END FUNCTION
' ========================================================================================
' ========================================================================================
' Unicode replacement for Free Basic's FileCopy.
' Returns 0 on success, or 1 if an error occurred.
' ========================================================================================
PRIVATE FUNCTION AfxFilecopy (BYVAL lpExistingFileName AS LPCWSTR, BYVAL lpNewFileName AS LPCWSTR) AS LONG
DIM nRet AS LONG = IIF(CopyFile(lpExistingFileName, lpNewFileName, FALSE) = 0, 1, 0)
RETURN nRet
END FUNCTION
' ========================================================================================