• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2189
  • Last Modified:

Detecting a DLL function exported as stdcall or cdecl?

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.
  • 3
1 Solution
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.  
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.
unsaAuthor Commented:
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??
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.)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now