• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 169
  • Last Modified:

Call a 32 bit dll in VB 5.0

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
pantosie
Asked:
pantosie
1 Solution
 
rmichelsCommented:
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
 
MirkwoodCommented:
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
 
pantosieAuthor Commented:
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
 
gsommerCommented:
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
 
MirkwoodCommented:
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now