VB 4.0 calling a Visual C++ 4.0 DLL 
Author Message
 VB 4.0 calling a Visual C++ 4.0 DLL

Hello:

I've created a DLL in Visual C++ 4.0 (Standard Edition) and am calling it
from VB 4.0.

A) Initially my function declaration was:

extern "C"
{
DllExport int cvt_timezone( char *in_datetime_str,
                                 int in_timezone,
                                 int in_DS_observed,
                                 int out_timezone,
                                 int out_DS_observed,
                                 char *out_datetime_str );

Quote:
}

I can call this DLL function from a VC++ console application, and am able
to step through it in the de{*filter*}.

In VB 4.0, I declared the following, remembering that a VC++ int is really
32bits:

Declare Function cvt_timezone Lib "cvttz.dll" (ByVal in_str$, ByVal in_tz&,
ByVal in_dso&, ByVal out_tz&, ByVal out_dso&, ByVal out_str$) As Long

I got the "Bad DLL calling convention (Error 49)" message.  (I tried
various changes in the declaration, and got the same error.)

B) One of the explanations from VB's help talks about needing the Pascal
calling convention, which is no longer supported directly in VC++ 4.0.  So,
from what I could understand from VC++'s help, I then declared the function
in VC++ 4.0 as:

extern "C"
{
DllExport int WINAPI cvt_timezone( char *in_datetime_str,
                                 int in_timezone,
                                 int in_DS_observed,
                                 int out_timezone,
                                 int out_DS_observed,
                                 char *out_datetime_str );

Quote:
}

This time I got a "Specified DLL function not found (Error 453)".

Can anyone tell me what I'm doing wrong and/or how to emulate the Pascal
calling convention in VC++ 4.0?

--Jenny



Sun, 22 Aug 1999 03:00:00 GMT  
 VB 4.0 calling a Visual C++ 4.0 DLL

Quote:

>Hello:
>I've created a DLL in Visual C++ 4.0 (Standard Edition) and am calling it
>from VB 4.0.
>A) Initially my function declaration was:
>extern "C"
>{
>DllExport int cvt_timezone( char *in_datetime_str,
>                             int in_timezone,
>                             int in_DS_observed,
>                             int out_timezone,
>                             int out_DS_observed,
>                             char *out_datetime_str );
>}
>I can call this DLL function from a VC++ console application, and am able
>to step through it in the de{*filter*}.
>In VB 4.0, I declared the following, remembering that a VC++ int is really
>32bits:
>Declare Function cvt_timezone Lib "cvttz.dll" (ByVal in_str$, ByVal in_tz&,
>ByVal in_dso&, ByVal out_tz&, ByVal out_dso&, ByVal out_str$) As Long
>I got the "Bad DLL calling convention (Error 49)" message.  (I tried
>various changes in the declaration, and got the same error.)
>B) One of the explanations from VB's help talks about needing the Pascal
>calling convention, which is no longer supported directly in VC++ 4.0.  So,
>from what I could understand from VC++'s help, I then declared the function
>in VC++ 4.0 as:
>extern "C"
>{
>DllExport int WINAPI cvt_timezone( char *in_datetime_str,
>                             int in_timezone,
>                             int in_DS_observed,
>                             int out_timezone,
>                             int out_DS_observed,
>                             char *out_datetime_str );
>}
>This time I got a "Specified DLL function not found (Error 453)".
>Can anyone tell me what I'm doing wrong and/or how to emulate the Pascal
>calling convention in VC++ 4.0?
>--Jenny

Hello

I have been struggling with the same problem this whole weekend. From
what  I gather from the discussions in the newgroup is that the
changing WINAPI in __stdcall should fix your problem:

DllExport int __stdcall cvt_timezone( char *in_datetime_str,
                                 int in_timezone,
                                 int in_DS_observed,
                                 int out_timezone,
                                 int out_DS_observed,
                                 char *out_datetime_str );

Provided that DllExport is defined as __declspec(dllexport) and
compile as a c (not c++) source.

I am going to try this tonight.
Hope I am right ;)

Taeke
0) Start signature.
1) Never attribute to malice what can be adequately explained by stupidity.
2) I'm not an official spokesman for ASZ.
3) End signature.



Fri, 27 Aug 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VB 4.0 calling Visual C++ 4.0 problem.

2. VB 4.0 calling Visual C++ 4.0 problem.

3. Visual Basic 4.0 usage of DLLs written in Visual C++ 4.0

4. Visual Basic 4.0 usage of DLLs written in Visual C++ 4.0

5. visual basic 4.0 call to borland c++ 5.0 dll

6. FS: Mastering Microsoft Visual Basic 4.0 and Visual C++ 4.0 CD-ROMs

7. DLL's in VB 5 or Visual c++ 4.0

8. Create DLL from C++ to be used call by VBasic 4.0 application

9. C++ DLL in Visual Basic 4.0

10. C++ DLL in Visual Basic 4.0

11. [Fwd: Visual Basic 5.0 to Visual C++ 4.0]

12. Scaling Printer Device Context between Visual Basic 4.0 and Visual C++ Problem

 

 
Powered by phpBB® Forum Software