Software Archive
Read-only legacy content
17061 Discussions

Re: Access Violation in Mixed CVF and Delphi

Jugoslav_Dujic
Valued Contributor II
625 Views
You should show us the relevant parts of Delphi caller also, especially declaration of DllRoutine1 and the calling code. The thing that structs my mind first is that DllRoutine should be declared in Delphi as stdcall (which is, to my recent surprise, not Delphi default -- it's something like register call) and dllimport.

You may debug your DLL from CVF to inspect values and LOCs of what's actually passed in (just set in Project/Settings/Debug/Executable for Debug Session the path to Delphi .exe). Without seeing your actual code, it's tough to say what went wrong.

Jugoslav
0 Kudos
2 Replies
Jugoslav_Dujic
Valued Contributor II
625 Views
Yes, that calling mechanism looks OK. My knowledge on Delphi is shallow;
however, the point is that you have to pass four addresses into the routine somehow. I think that alternate calling procedure would be:

 
procedure DLLRoutine1(var Array1, Array2, Array3, Array4: pointer); stdcall; external 'MyDll.dll';  
... 
DLLRoutine1(@Array1, @Array2, @Array3, @Array4);  


Maybe declaration that arguments are array of whatever should also work, provided that call-array-by-reference is Delphi's default. In that case, only Arrays should appear in actual arg-list (without @).

As for debugging, you should do the following:

- In Visual Studio, in Project/Settings/Debug/Executable for Debug Session box, enter the name of Delphi executable,

- Make sure there's a copy of your Dll in exe's directory or in PATH. AFAIK, that copy serves only to make the exe happy; it's not actually being called, but the one you debug, i.e. the one in your .../DllProject/Debug directory (however, I'm not 100% sure about the latest statement).

- Set breakpoints in your Dll as desired.

- Debug/Go (F5). You'll get the warning that the .exe doesn't contain debug info -- ignore it. The exe starts normally -- do the necessary steps
in it to invoke Dll and voila -- the debugger stops at the breakpoint.

HTH

Jugoslav
0 Kudos
jlb
Beginner
625 Views
See at http://www.nag.co.uk/numeric/BorlandDelphi.asp to know how to call fortran dlls from Delphi and how to pass the parameters like integer, string, function, procedure, multi-dimensional arrays

Jean-Luc
0 Kudos
Reply