- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
IMO the simplest mechanism is to pass address of a Delphi callback function into a Dll. The callback need not be in Delphi DLL, but you must follow guidelines for mixed-language programming. STDCALL calling convention is kinda standard for mixed-language stuff, so your code should look something like:
I don't speak Delphi best, so I might have made some syntax error,
but I hope you get the idea.
One final remark: if you have to call fnCallback from somewhere deep in the dll's calling tree, it's sufficient that you pass fnCallback through all arg-list declared as EXTERNAL. Only in the routine that actually calls fnCallback you'll need full INTERFACE.
HTH
Jugoslav
SUBROUTINE MyFortranDll(..., fnCallback) !DEC$ATTRIBUTES DLLEXPORT, STDCALL, ALIAS: "_MyFortranDll@XXX":: MyFortranDll INTERFACE SUBROUTINE fnCallback(n) !DEC$ATTRIBUTES STDCALL:: fnCallback INTEGER n END SUBROUTINE END INTERFACE DO i=1, large_computation ... CALL fnCallback(i) END DO ... !---8<--Callback in Delphi: ----------- procedure DllProgressBar( nProgress: integer); stdcall; ... {do something with progress indicator here} ... end; !---8<--Delphi's calling routine: ----------- procedure MyFortranDll(... fnCallback: pointer); stdcall; external "MyDll.dll"; ... MyFortranDll(... @DllProgressBar);
I don't speak Delphi best, so I might have made some syntax error,
but I hope you get the idea.
One final remark: if you have to call fnCallback from somewhere deep in the dll's calling tree, it's sufficient that you pass fnCallback through all arg-list declared as EXTERNAL. Only in the routine that actually calls fnCallback you'll need full INTERFACE.
HTH
Jugoslav
Link Copied
0 Replies

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page