Solved

Call a 32 bit dll in VB 5.0

Posted on 1998-11-20
5
136 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

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