[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

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
0
AVsystem
Asked:
AVsystem
1 Solution
 
sudhakar_koundinyaCommented:

Type iotmodule_t
    ucType As Byte
    csName As String
    usTotalNoInputs  As Byte
    usNoAnalogeInputs As Byte
    usNoDigitalInputs As Byte
    usTotalNoOutputs As Byte
    usNoAnalogeOutputs As Byte
    usNoDigitalOutputs As Byte
End Type

Type iotlayout_t

  usTotalNoInputs As Byte
  usTotalNoOutputs As Byte
  usNoIOmodules As Byte
  IOmoduleInfo As iotmodule_t
End Type



Public Declare Function iotsvc_Open(byref pulHandle as byte, byref csTarget as string ,  byref pLayout as iotlayout_t)as integer


is this stuff is helpful to you

some minor changes may be required in that. I haven't put exactly same as your structures as i am in hurry now
0
 
SmallintCommented:
Hi AVsystem,

C function must be defined with _stdcall

Take a look here, may is helpful for you

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20608530.html

Cheers

0
 
AVsystemAuthor Commented:
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
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now