Solved

Cannot access function in C DLL with VB

Posted on 2003-11-20
3
246 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
Comment Utility

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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now