Solved

Cannot access function in C DLL with VB

Posted on 2003-11-20
3
250 Views
Last Modified: 2010-05-03
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
Comment
Question by:AVsystem
3 Comments
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 50 total points
ID: 9795102

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
 
LVL 7

Expert Comment

by:Smallint
ID: 9795511
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
 

Author Comment

by:AVsystem
ID: 9809577
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question