Private Declare iotsvc_Open Lib "dllname.dll" (pulHandle As Long, ByVal csTarget As String, pLayout As iotlayout_t) As Long
There is no such thing as type 'char' in VB6 and strings must ALWAYS be declared ByVal so that the pointer to the string is passed and not the pointer to the variable.
I'am still 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 ??
I already stated the function declaration in my previous post. Here's the structure declarations:
Private Type iotmodule_t ucType As Byte csName As String * 16 usTotalNoInputs As Integer usNoAnalogeInputs As Integer usNoDigitalInputs As Integer usTotalNoOutputs As Integer usNoAnalogeOutputs As Integer usNoDigitalOutputs As Integer End Type
Private Type iotlayout_t usTotalNoInputs As Integer usTotalNoOutputs As Integer usNoIOmodules As Integer IOmoduleInfo(MAX_NO_IO_MODULES) As iotmodule_t End Type