Link to home
Start Free TrialLog in
Avatar of AVsystem
AVsystemFlag for Netherlands

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_MODULES];
} 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
Avatar of sudhakar_koundinya
sudhakar_koundinya

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Smallint
Smallint

Hi AVsystem,

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

Avatar of AVsystem

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