?
Solved

Call a 32 bit dll in VB 5.0

Posted on 1998-11-20
5
Medium Priority
?
160 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
[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
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 200 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

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!

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

801 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