G
Guest
I have read several interesting posts on passing structures to C dlls, but none seem to cover the following case. The structure (as seen in C) is as follows:
typedef struct tag_scanparm
{
short cmd;
short fdc;
WORD dsf;
short boxcar;
short average;
short chan_ena[\4];
short scan_dark;
short correct_dark;
short extrig;
short upper4chan;
float sdat[\4][\2048]
} SCANPARM;
The real problem seems to be with the arrays. Even using attributes and specifying a size when I decalre the structure in VB, I can't get this to work. It has to be passed by reference, and when I call "GetType" as a part of my call to Marshall.StructureToPtr, I get an error message to the effect that my structure cannot be marshalled as an unmanaged type.
Please forgive the fact that I don't have the exact error message handy...I tried getting this to work for about a day, scanning all types of message boards, and finally threw in the towel and created a COM object in C++ that wrapped the calls to this 3rd Party dll. That's OK for me, but for some of our customers who use VB exclusively it would be nice to know how to do this directly from VB...there has to be a way, and I think I was close!
Any help would be greatly appreciated!
Thanks,
Steve
typedef struct tag_scanparm
{
short cmd;
short fdc;
WORD dsf;
short boxcar;
short average;
short chan_ena[\4];
short scan_dark;
short correct_dark;
short extrig;
short upper4chan;
float sdat[\4][\2048]
} SCANPARM;
The real problem seems to be with the arrays. Even using attributes and specifying a size when I decalre the structure in VB, I can't get this to work. It has to be passed by reference, and when I call "GetType" as a part of my call to Marshall.StructureToPtr, I get an error message to the effect that my structure cannot be marshalled as an unmanaged type.
Please forgive the fact that I don't have the exact error message handy...I tried getting this to work for about a day, scanning all types of message boards, and finally threw in the towel and created a COM object in C++ that wrapped the calls to this 3rd Party dll. That's OK for me, but for some of our customers who use VB exclusively it would be nice to know how to do this directly from VB...there has to be a way, and I think I was close!
Any help would be greatly appreciated!
Thanks,
Steve