plugins and structures

I have to use an external windows dll, which has calls with a lot of C-structures. Therefore I wrote a RB-plugin, but it runs into some problems:

  1. If using (sub) structures as element of a structure, the values of the substructers are lost in the plugin.
  2. There’s a strange behaviour if an element is defined as an array.
  3. The same with using a as Ptr for double* a.
    So my question in general: Is it possible to use Substructures, Array and Pointers within structures when using it for data exchange with c-plugins?
    Thanks, Matti

It might be easier to use declares from Xojo code. Depending on the semantics of the DLL methods, you’ll pass allocated MemoryBlocks as Ptrs, or have them set by the DLL. Have you at least looked into the feasibility of that before trying to write a wrapper plugin?

This means, if I use declares, I can’t use RB-structues as parameters, and I have to set up the c-structures as memoryblocks?

That’s typically what you would do. But if you create a plugin bridge, you have to do that anyway, except in C to bridge Xojo structures with what your DLL expects.

There’s a tipping point where it’s easier and cleaner to write a plugin than to create a module of declares. But it’s probably not for just a few routines, and it may push higher as you get more comfortable writing the declares. I’d just try out the declares angle to see if it’s workable first.

Thanks Richard, I’m not sure what’s better, but I will try and decide. But coming back to my first questions, it would be interesting, if anybody know if substructures, arrays and pointers are exchangeable between C and RB/Xojo structures.

I use RB structures in declares all the time. Write your declare using the structure as a parameter, e.g.

Declare Function FindFirstFileW Lib "Kernel32" (FileName As WString, ByRef FindData As WIN32_FIND_DATA) As Integer Dim FindData As WIN32_FIND_DATA 'An RB/Xojo structure Dim FindHandle As Integer = FindFirstFileW(MyFolder.NativePath, FindData)