Note that there are some explanatory texts on larger screens.

plurals
  1. POcan I mix __cdecl export calls with __stdcall import calls in a DLL?
    text
    copied!<p>I am writing a module for a third party application; the application <code>uses __cdecl</code> calling convention. </p> <p>At the same time, I have a legacy DLL which <code>uses __stdcall</code> calling convention.</p> <p>Can I create a wrapper that in one end <code>exports __cdecl</code> functions, while in the other end <code>imports __stdcall</code> functions? which other options do I have?</p> <p>Thanks,</p> <p>EDIT:</p> <p>Here is some extra information that my help clarify my situation.</p> <p>There is a <code>third_party.exe</code> that need to gain access to <code>skeleton.dll</code>. The source code skeleton.dll contains the header file below and compiles using __cdecl.</p> <pre><code>#ifdef _EXPORTING #define DECLSPEC __declspec(dllexport) #else #define DECLSPEC __declspec(dllimport) #endif #ifdef __cplusplus extern "C" { #endif DECLSPEC int ICD_Create(char* id); ... ... ... </code></pre> <p>Ideally, I would use the skeleton source code to develop my DLL; unfortunately, it would be too time consuming to port my current VB6 legacy code into C++. Given this, I had to hack my VB6 code by following <a href="http://www.google.com/url?sa=t&amp;source=web&amp;cd=2&amp;ved=0CCEQFjAB&amp;url=http://filedb.experts-exchange.com/incoming/2011/04_w16/443022/VB6-Library-Guide-Rev1.pdf&amp;rct=j&amp;q=building%20shared%20libraries%20with%20vb6&amp;ei=2FQ4TrOCFabe0QHyxq3eAw&amp;usg=AFQjCNG1UZrN37UPFIKboP0W4zKul-6CJQ&amp;cad=rja" rel="nofollow">this guideline</a> (It is a work around, but it allows me to use an ActiveX DLL as a standard C DLL). </p> <p>I am not 100% confident of the modified VB6 calling convention, nor how to modify it. The exercises use __stdcall, and there seem to work fine with a test application I developed. However, when I test it with the third party application, it calls properly certain functions but in other functions it crashes.</p> <p>The architecture would look like:</p> <pre><code>Application: ThirdParty.exe (out of your control: Uses __cdecl) | | Plugin module: Skeleton.dll (your code) | | Legacy DLL: ModifiedVB6.dll (out of your control: Seem to work with __stdcall) </code></pre> <p>The legacy DLL generates a dll, lib and def file; No header file.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload