Solved

Call a 32 bit dll in VB 5.0

Posted on 1998-11-20
5
149 Views
Last Modified: 2010-05-03
I have an application that calls a DLL. The dll is written in c. One of the elements that is passed to the dll is a defined type (structure in c). The structure occurs more than once. It is an array of structures. When I return from the dll I receive an access violation. If I change the structure to a string and call the DLL the program returns the data fine. I have no idea why!
0
Comment
Question by:pantosie
5 Comments
 
LVL 3

Expert Comment

by:rmichels
ID: 1445978
Did you write the C dll?  Can you post the code, from VB and C..the declare and call from VB (along with the user defined type  for the structure)..and the code in C (the function definition especially)..but also the code in the function
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1445979
Take a look at this website. It shows you the maximum of what you can do with structs and VB/C

http://www.worldofatl.com/LegalDownload.asp?URL=Downloads/WorksWithVB.zip&DESC=Structs & VB&LIB=True
0
 

Author Comment

by:pantosie
ID: 1445980
The answer was just a referral to a web site. I hav done some investigation and I ascertained the follwing. I have 3 choices:
1) Pass the data as a string
2) Rewrite the C so it wil accept a safe array. When you pass structures in VB 5 it passes an array of pointers to each ocurrence. You must change the c.
3) Place a wrapper around the old 16 bit DLL and call it from the wrapper (thunk script)
0
 

Expert Comment

by:gsommer
ID: 1445981
You need to give us more information, like what the structure is that you are passing, and whether the data is going in to the DLL, out from it, or both.

Also, how does the DLL know how many elements are passed in through the array?  Is there another parameter that contains that value?
0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 100 total points
ID: 1445982
When your DLL is a 16 bit dll, you have no choice but to create a thunk. (This is really horrible to do btw).

Otherwise the "just a  reference" is the best answer you could get. It includes a sample of what is possible and what is not.
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

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