Note that there are some explanatory texts on larger screens.

plurals
  1. POVB6 dll call to win32 C function
    text
    copied!<p>I need to write some functions in C for someone else's VB6 project (that being outdated is beyond the scope of this question).</p> <p>During initial tests, I could not get the calls to work. I have supplied a .def file, I tried to use __declspec(dllexport), stdcall and WINAPI calling conventions. Each call I get an error message in VB6 saying "bad dll calling convention."</p> <p>Win32 C function prototypes:</p> <pre><code>long WINAPI BitmapFile_Open(char *pszFileName); void WINAPI BitmapFile_Close(long bmf); </code></pre> <p>note in the above I have tried several other calling conventions, including __declspec(dllexport) and stdcall, and neither work.</p> <p>Def file:</p> <pre><code>LIBRARY ImageLib EXPORTS BitmapFile_Open @1 BitmapFile_Open @2 </code></pre> <p>VB Global Module:</p> <pre><code> Declare Function BitmapFile_Open Lib "ImageLib.dll" (ByVal fileName As String) As Long Declare Function BitmapFile_Close Lib "ImageLib.dll" (ByVal bmFile As Long) </code></pre> <p>VB Code:</p> <pre><code>Dim myFile As Long myFile = BitmapFile_Open("test.bmp") BitmapFile_Close (myFile) </code></pre> <p>Also note that in the original functions, the bmFile is actually an address (pointer to a structure) but in VB it will be represented as long. However, since VB6 doesn't support pointers, I am casting from long in the C code. I hope you can understand what I'm trying to get at here. It has nothing to do with the error that is occurring. Any help is appreciated.</p> <p>Edit: I have used a dependency walker to determine that the functions are indeed being exported. VB6 is just not calling them without error.</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