LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bad DLL Calling Convention

Hi,

 

I've created a dll with LV8.6 and I'm trying to call it from VB6.0.  I get the message 'Bad Dll Calling Convention.  Run Time Error '49'.

 

Questions:

1.  Any idea what might cause this error?

2.  What is the meanig of the second function appear inh the h file ( long __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module)😉

 

Thanks very much for your help

Rafi

 

 

 

The dll definition as appear in the h file:

     void __stdcall EDASAnalysis(double f_sampleMHz, char FilePathFromOut[],
         double *RMSValue, double *AmplitudePP);

     long __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module);
 

The Decleration in Visual Basic 6.0:

     Declare Sub EDASAnalysis Lib "D:\NI Projects\eDAS400\DLL\ LV-DLL_V2\DLL\eDAS400_Analysis.dll" _
            (ByVal f_sampleMHz As Long, ByVal FilePath As String, RMSValue As Long, AmplitudePP As Long)

 

Using the Function in VB6.0:

    Call EDASAnalysis(10, "D:\NI Projects\eDAS400\Data Files\Samples\10MHz.txt", rms, pp)
 

 

0 Kudos
Message 1 of 4
(4,067 Views)
0 Kudos
Message 2 of 4
(4,036 Views)

Rafi2003 wrote:

Hi,

 

I've created a dll with LV8.6 and I'm trying to call it from VB6.0.  I get the message 'Bad Dll Calling Convention.  Run Time Error '49'.

 

Questions:

1.  Any idea what might cause this error?

2.  What is the meanig of the second function appear inh the h file ( long __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module)😉

 

Thanks very much for your help

Rafi

 

 

 

The dll definition as appear in the h file:

     void __stdcall EDASAnalysis(double f_sampleMHz, char FilePathFromOut[],
         double *RMSValue, double *AmplitudePP);

     long __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module);
 

The Decleration in Visual Basic 6.0:

     Declare Sub EDASAnalysis Lib "D:\NI Projects\eDAS400\DLL\ LV-DLL_V2\DLL\eDAS400_Analysis.dll" _
            (ByVal f_sampleMHz As Long, ByVal FilePath As String, RMSValue As Long, AmplitudePP As Long)

 

Using the Function in VB6.0:

    Call EDASAnalysis(10, "D:\NI Projects\eDAS400\Data Files\Samples\10MHz.txt", rms, pp)
 

 


muks already pointed you to a discussion that shows the problem. VB can not call cdecl exported functions, so when you create your DLL you'll have to tell LabVIEW to use the stdcall calling convention to export the function for VB.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 4
(4,031 Views)
Thank you both for answering, rolfk, I'm aware to the fact that VB need the standard convention and this is exactly what I've used. Please look again at the h file generated by LV void __stdcall EDASAnalysis(double f_sampleMHz, char FilePathFromOut[], double *RMSValue, double *AmplitudePP); long __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module); The first line is my function and it uses the stdcall. The second line was generated automatically and I don't know what it means and what it is used for. IT WAS GENERATED BY LV. I decided to experiment with the most simple fucntion and I build a dll that add 2 numbers. The 2 parameters are used byVal and the result is returned by ref. The function is working and I can see the correct result. However the same error is still displayed "Bad DLL Calling Convention" I attached a zip file that contains the vi, LV project and VB6 project. I would appreciate if anybody can run it and find out why this error is displayed. Thanks Rafi
0 Kudos
Message 4 of 4
(3,997 Views)