[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Calling CDecl funcitons in a DLL from VB+

Posted on 1998-01-13
Medium Priority
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...
Question by:LMSuporte
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
  • 2

Author Comment

ID: 1450814
Edited text of question

Expert Comment

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.

Accepted Solution

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


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

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

656 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