# Windows API help with CopyFileExA() and Callback to show Progress

**URL:** <https://clarionhub.com/t/windows-api-help-with-copyfileexa-and-callback-to-show-progress/5388>\
**Category:** questions\
**Tags:** winapi\
**Created:** [August 31, 2022, 2:42pm UTC](https://clarionhub.com/t/windows-api-help-with-copyfileexa-and-callback-to-show-progress/5388 "2022-08-31T14:42:38Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![anon23294430](https://clarionhub.com/user_avatar/clarionhub.com/anon23294430/32/3829_2.png) [@anon23294430](https://clarionhub.com/u/anon23294430)\
**Post date:** [August 31, 2022, 4:43pm UTC](https://clarionhub.com/t/windows-api-help-with-copyfileexa-and-callback-to-show-progress/5388/4 "2022-08-31T16:43:52Z")

</div>

I’ve only used copyfileA in some template Dll’s to move files around so far, but I can see CopyFileEx has the same two parameters as CopyFileA

```
BOOL CopyFileExA(
  [in] LPCSTR lpExistingFileName,
  [in] LPCSTR lpNewFileName,

```

[CopyFileA function (winbase.h) - Win32 apps | Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-copyfilea)

```
BOOL CopyFileA(
  [in] LPCSTR lpExistingFileName,
  [in] LPCSTR lpNewFileName,

```

some hints  
lp = Long Pointer which is a Long in Clarion.  
another way of expressing a long point is to use the \*before the data type, most will be familiar with \*cstring as a parameter, but you could do \*long, and others.  
It boils down to do you want clarion to do this for you  
Loc:Address1 long  
Loc:Address2 long  
Loc:Bool bool  
Loc:ReturnValueBool bool  
Loc:Cstring1 cstring(1000)  
Loc:Cstring2 cstring(1000)  
Loc:ReturnValueBool = CopyFileA(Loc:Address1,Loc:Address2,Loc:Bool)  
Peek(loc:Address1,Loc:cstring1)  
Peek(loc:Address2,Loc:cstring2)

TLDR \* = Peek(LongPointer,DestinationVariable)

As this is attached to a Cstr  
[[MS-DTYP]: LPCSTR | Microsoft Docs](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/f8d4fe46-6be8-44c9-8823-615a21d17a61)

its a CONST in the clarion parameter and it say in the description its a null terminated string of ansi characters. So as its null terminated you would need to use a Clarion cstring as that is also null terminated.

So you have two ways to do the api prototype in Clarion  
CopyFileA(long,long,bool),Bool,Pascal,Name(‘CopyFileA’)  
or  
CopyFileA(CONST \*cstring, CONST \*cstring,bool),bool,Pascal,Name(‘CopyFileA’)  
In clarion CONST tells clarion the parameter being passed by address can not be changed, its treated as a read only a parameter. However you can leave the CONST out of the prototype so it looks like this  
CopyFileA(\*cstring, \*cstring,bool),bool,Pascal,Name(‘CopyFileA’)

Personally I’d get copyFileA working first and then try the CopyFileExA.

Common windows data types can be found here  
[[MS-DTYP]: Common Data Types | Microsoft Docs](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/efda8314-6e41-4837-8299-38ba0ee04b92)

Common windows base types can be found here  
[[MS-DTYP]: Common Base Types | Microsoft Docs](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/3caa4769-b02f-4cee-a857-8496f4395ec1)  
so it should be possible to work out what data type you need or group structure you need to make if you are getting into 64bit territory.

and for callbacks, this might help you

> [@How can I access the raw stack data? MS callback proc prototype changes when asm starts popping the stack](https://clarionhub.com/t/how-can-i-access-the-raw-stack-data-ms-callback-proc-prototype-changes-when-asm-starts-popping-the-stack/5377/18):
>
> For these apis and their Ex versions [EnumResourceTypesA function (winbase.h) - Win32 apps | Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-enumresourcetypesa)[EnumResourceNamesA - Win32 apps | Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-enumresourcenamesa)[EnumResourceLanguagesA function (winbase.h) - Win32 apps | Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-enumresourcelanguagesa) with these callback procedures [ENUMRESTYPEPROCA (libloaderapi.h) - Win32 apps | Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nc-libloaderapi-enumrestypeproca)[ENUMRESNAMEPROCA (libloaderapi.h) - Win32 apps | Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nc-libloaderapi-enumresnameproca)[EnumResLangProc callback function (Windows) | Microsoft Docs](https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms648033(v=vs.85)) there is no combination of pragma stateme…

fwiw.

---

_[View the full topic](https://clarionhub.com/t/windows-api-help-with-copyfileexa-and-callback-to-show-progress/5388)._
