Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing arrays to .dll declared in C.

Status
Not open for further replies.

oscarmv

Programmer
Jan 15, 2003
1
ES
Greetings there. I'm trying to call a .dll built in C from a Delphi application I'm developing.

When declaring the pascal equivalents of the functions in the C .dll exports declaration, I was using &quot;var ... : array of <type>&quot; when the C function asked for a pointer to <type> (an equivalent basic type of record/struct). I realized that lead to big, crashing errors as delphi put an extra element on the stack with the High index of the array.

I know I can sort out the problem by declaring the pascal equivalent as passing a pointer to the first element of the array. However, as the C exported functions in the .dll are custom made for the delphi application, I wanted to know if 1) It would work if I declared a pointer and an unsigned integer as parameters in the C function and an array in the delphi equivalent. 2) If this parameter passing protocol isn't going to change in the future, so it's safe to use.

Thanks for your help in advance.
 
In my Delphi program using a C++ written DLL I had no problems. One small thing I had to do is using the compiler directive &quot;stdcall&quot; after my Delphi function declaration.

Roderich
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top