AVsystem
asked on
Cannot access function in C DLL with VB
Hi,
I'am having difficulties in VB with the use of a function call in a certain C DLL.
The DLL function is described below. There is a struct in it aswell.
Hopefully you have an answer to this. I tried a lot but nothing will work.
int IOTSVC_API iotsvc_Open(unsigned long *pulHandle, char *csTarget, iotlayout_t *pLayout);
typedef struct
{
unsigned char ucType;
char csName[16];
unsigned short usTotalNoInputs;
unsigned short usNoAnalogeInputs;
unsigned short usNoDigitalInputs;
unsigned short usTotalNoOutputs;
unsigned short usNoAnalogeOutputs;
unsigned short usNoDigitalOutputs;
} iotmodule_t;
typedef struct
{
unsigned short usTotalNoInputs;
unsigned short usTotalNoOutputs;
unsigned short usNoIOmodules;
iotmodule_t IOmoduleInfo[MAX_NO_IO_MOD ULES];
} iotlayout_t;
How should i declare this in VB and how can i access the C function in VB.
Thank for your help
AVI
I'am having difficulties in VB with the use of a function call in a certain C DLL.
The DLL function is described below. There is a struct in it aswell.
Hopefully you have an answer to this. I tried a lot but nothing will work.
int IOTSVC_API iotsvc_Open(unsigned long *pulHandle, char *csTarget, iotlayout_t *pLayout);
typedef struct
{
unsigned char ucType;
char csName[16];
unsigned short usTotalNoInputs;
unsigned short usNoAnalogeInputs;
unsigned short usNoDigitalInputs;
unsigned short usTotalNoOutputs;
unsigned short usNoAnalogeOutputs;
unsigned short usNoDigitalOutputs;
} iotmodule_t;
typedef struct
{
unsigned short usTotalNoInputs;
unsigned short usTotalNoOutputs;
unsigned short usNoIOmodules;
iotmodule_t IOmoduleInfo[MAX_NO_IO_MOD
} iotlayout_t;
How should i declare this in VB and how can i access the C function in VB.
Thank for your help
AVI
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi, AVsystem here,
It still wo'nt work.
Probably the data definitions are not mapped from C to VB.
There is defined an unsigned long, unsigned short and a unsigned char.
Is there someone that has enough expierience to tackle this for me.
Greetings AVI
It still wo'nt work.
Probably the data definitions are not mapped from C to VB.
There is defined an unsigned long, unsigned short and a unsigned char.
Is there someone that has enough expierience to tackle this for me.
Greetings AVI
C function must be defined with _stdcall
Take a look here, may is helpful for you
https://www.experts-exchange.com/questions/20608530/calling-dll-from-vb6-with-struct-argument.html
Cheers