[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Calling CDecl funcitons in a DLL from VB+

Posted on 1998-01-13
3
Medium Priority
?
675 Views
Last Modified: 2008-02-01
     We would like to call DLL functions from a dll written in C Laguage. We all know that it is ok to do so in VB if the dll use standart declarations, but we have a problem here. The dll we want to call the function from, is entire wirtten using the C_Declare, what turns impossible(?!?) to call them.
      In order to avoid to use all those non-professional OCXs and VBXs and other Computer Telephony toolkits, we would like to call the Dialogic boards directly throu their dll, using their API. Using their dlls directly we will be able to save about 90% of memory and also we will be able to use threads.
      We have all the documentation to convert the *.H files to *.bas files. For exemple:      

            -in the *.h file we have:
            extern int dx_open( const char *namep, int oflags );

            -what becomes a *.bas file in VB5:
            declare function dx_open& lib "libdxxmt.dll" (byval char as string, byval oflags as long)

      The problem is that we will get a"Bad DLL calling convention" anyway. The DLL is is not acessible from VB becuse it is expecting a "standart declaration".
      We have been searching the web and asking the PROs, and it seems that we would have to either re-write the dll using standart declaration (which is  impossible since it is how the toolkit developers makes money) or write a "Wrapper DLL" to translate the calls.

The DLL vendor told me that it's necessary to write a "wrapper" DLL in C
language to translate the calls.

We would like to know if there is a work around, and how can we write a multithreaded wrapper dll without the original dll source code..

I Hope this helps, and I hope someone helps me!
Thanx in advance...
Gutto
0
Comment
Question by:LMSuporte
  • 2
3 Comments
 

Author Comment

by:LMSuporte
ID: 1450814
Edited text of question
0
 
LVL 4

Expert Comment

by:rantanen
ID: 1450815
That is true, you can't do it without a wrapper DLL.

VB 4.0 had a bug which allowed the EXE version to call _cdecl declared functions, even if in IDE mode generated the error you mentioned. I don't know if VB 5.0 still has this bug - anyway you shouldn't trust on bugs :-)

To get started, lookup following MS Knowledge Base Article

How to Call C Functions That Use the _cdecl Calling Convention

Last reviewed: July 16, 1996
Article ID: Q153586

It is not very helpful, but just confirms what you have been told.
0
 
LVL 4

Accepted Solution

by:
rantanen earned 600 total points
ID: 1450816
I just forgot ... you can do these kind of calls in Basic ... not in VB, in PB/DLL. It can use CDECL calling convention, so you can write your wrapper DLLs in PB/DLL or you can write most of your app in it and only create user interface in VB.

Check out at

http://www.powerbasic.com/pbdll/pbdllwht.html

I am making this an answer ... if you think you can get a better one from this forum, please feel free to reject it.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month19 days, 7 hours left to enroll

834 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