?
Solved

Cannot access function in C DLL with VB

Posted on 2003-11-20
3
Medium Priority
?
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 150 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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 While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month10 days, 17 hours left to enroll

770 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