12-04-2009 09:19 PM - edited 12-04-2009 09:28 PM
I found this discussion on delphi calling conventions and interoperability with other languages:
http://www.swissdelphicenter.ch/torry/showcode.php?id=1233
It looks like you can easily cause Delphi to use stdcall or cdecl. BUT the default calling convention, at least for many versions of Delphi, is either pascal or register, neither of which is stdcall or cdecl.
And I saw in another link that the pascal calling convention with Delphi is rarely used anymore, so unless this is really old code or has been developed with an old version of Delphi, it's probably not the issue.
Have you tried looking at the dll with depends.exe (part of Visual Studio)? Gives you some insight as to what's happening inside of a DLL.
I think there's a dependency walker in the sysinternals suite that might get you some info too.
Menchar
12-07-2009 09:16 AM
The Delphi dll was built to use stdcall I've found some documentation on attaching the debug version of the DLL to the running process that hopefully would let me use the Delphi debugger when CVI calls the DLL function. I'm trying to set this up now.
--wally.
12-29-2009 02:00 PM - edited 12-29-2009 02:01 PM
After beating my head against the wall on this for a good while I was finally able to learn enough Delphi to build a sample program that exercised the key features and then built the code as a dll instead of an exe. Calling this dll worked as expected from CVI with parameters and return values coming through OK.
I was convienced it was a Delphi issue in his code from the beginning, but I sent this sample code to my Delphi using colleague last week and he was able to by analogy figure out which Delphi top level object he used that I didn't which was causing the issue.
He send me a dll that works correctly today.
Thanks for all the comments that kept me going at it, knowing that it should work helped.
Googling produced some info about situations were Delphi (versions 5 & 6 at least) took 4 bytes off the stack when it should have been taking 8, so it became a treasure hunt to find the buggy top level Delpi object and use a variant that worked correctly.
--wally.