PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Using a DLL which requires a callback to a function
Using a DLL which requires a callback to a function
Iniciado por guest, 16,abr. 2015 16:04 - 6 respuestas
Publicado el 16,abril 2015 - 16:04
Hello,

I have a library which i wrote using C. Now, I am trying integrate this library in to Windev windows application which I a creating, and i'm facing a serious problem. Below is API call I am doing

value = API("<LIB_NAME", "API_NAME", &callback)

where callback is my global procedure. Based on a particular event my library will do a call back. Now I am getting the callback after the event, but the application is getting crashed after this. Below is the error I am getting
"Run - Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declaredwith a different calling convention."

As the error says it is parameter mismatch. but in my case just see below:

1. Callback declaration in Library : int (*Notification_CB_t) ( int type, int a, int b, int test);
2. One of API call: value = API("<LIB_NAME", "API_NAME", &callback)
3. Callback procedure definition : PROCEDURE callback(Type is int,DataInfo is int, TagInfo is int, local_status is int)

Any help is appreciated since I am new to WinDev
Publicado el 16,abril 2015 - 16:18
Hi

in your callback function, try declaring your parameters as system int instead

Best regards
Publicado el 16,abril 2015 - 17:51
Hi Naveen,

Alors check which calling convention you are using in your DLL. By default in WinDev uses SDTCALL. You must inform WinDev if this is CDECL (or THISCALL) in your callback function.

For example:

PROCEDURE MyCallback(n is sys int)

(Yes, this is French and there is no English version of it; this will work).

Best regards,
Alexandre Leclerc
Publicado el 17,abril 2015 - 12:25
Hi Alexandre,

Thaks for the reply. It workd after I mentioned (--stdcall) in my library for the callback decalration. Is there any provision to keeo the status as SOLVED for my post?

Thanks,
Naveen Rathan
Publicado el 17,abril 2015 - 15:49
Hi Naveen,

When you click "Reply" you can change the subject line. Add [SOLVED] if you want!

Best regards,
Alexandre Leclerc
Publicado el 17,abril 2015 - 19:11
I hope this helps Must use [SDECL]

FUNCTION DiskRead SDECL ALIAS "DiskRead"(BYVAL hDisk AS DWORD, BYVAL pBlockIndex AS QUAD POINTER, BYVAL pBuffer AS DWORD, BYVAL BufferLen AS DWORD) EXPORT AS DWORD


//WinDev code
qBlockCount = CallDLL32("SectorReader.dll", "DiskRead", (hDisk), &sBuffer, (BufferByteSize))
Publicado el 20,abril 2015 - 09:24
Done.

Thanks <img src="/NG2013_WEB/ui/smiley/1.gif" align=absmiddle border=0 alt=":)">