Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Detecting a DLL function exported as stdcall or cdecl?

Posted on 1999-06-30
4
Medium Priority
?
1,995 Views
Last Modified: 2010-05-19
Hi,
I have some DLLs which can be used in C but I need to use them in visual basic. Can I detect how DLLs were exported? using stdcall or cdecl?? if cdecl then can I call functions in the DLLs from VB or are there a tool to convert cdecl functions to stdcall?* consider I have not DLL source.
0
Comment
Question by:unsa
[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
  • 3
4 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1198805
You can look at the names of the exported function.  (use Microsoft's DumpBin.exe or right click on the dll in the explorer window.)  If the name of the function contains a "@" then the function is very likely stdcall.  Otherwise it probably is cdecl.  
0
 
LVL 22

Accepted Solution

by:
nietod earned 90 total points
ID: 1198806
If the function is cdecl, there appears to be no way that VB can call it directly.  
However, you still can make it work.  What you need to do is to write an "interface library" DLL in C/C++.  Just write a DLL that has functions that coorespond to all the cdecl functions you need to call from VB.  (Write these as stdcall functions.)  Then have this interface DLL "forward" the call on to the other DLL.

Let me know if you have any questions.
0
 

Author Comment

by:unsa
ID: 1198807
Yes it is a solution. But before it I wanted to be sure about which function is declared as stdcall.
Another question then;
1.All win32 APIs are exported as __stdcall? and what to do when calling functions exported as stdcall from C?

if I calling a function in the DLL with the same name which is seen by right clicking on dll file and selecting view, then it is likely a cdecl function??
0
 
LVL 22

Expert Comment

by:nietod
ID: 1198808
1.  Are you asking if there is a difference between __stdcall and stdcall?  No there shouldn't be.  __stdcall is a #define from the windows include files that should produce the stdcall calling convention

2. if the function name has a @f ollowed by number it probably uses the stdcall calling convention.  Otherwise it probably uses the cdecl calling convention.  (This is true if the DLL was produced by a C/C++ compiler.  If produced by another langauge, there could be other calling conventions as well.)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

660 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