Passing user-defined types from VBA to C DLL
I am writing a DLL in C to replace some functions in an Excel VBA module. I have replaced many of these successfully but have now reached the point where I need to pass user-defined types (UDT) to the DLL as function parameters.
The simplest of the UDTs has 14 elements all of type 'single', none of which are arrays. The most complex has 52 singles, 2 doubles, 2 arrays of variable-length strings and one variant (yes, I know, but it's someone else's code and I'm stuck with it).
Starting with the simpler one I set up a 'typedef struct' arrangement in C that has 14 elements of type 'float'. I created a test function that took one of these structs as its parameter. In VBA I called the function, passing the UDT variable ByRef.
Debug mode showed that the values that the C function received were not the values that the original UDT variable contained.
Could anyone point out where I am going wrong? I haven't been able to find anything that explains how to do this, probably because I couldn't find a decent way to phrase the question in Google. I did find some resources that indicate I may have to use something called SAFEARRAY, but the documentation I can find for this assumes more knowledge than I have (this DLL is my first Windows project).
A 'here's how to do it' answer would be great, but so would a 'here's where to look it up' one!