|
-
February 8th, 2000, 10:32 AM
#1
DLL Problem
I have a problem linking a VB app to a C++ Win32 DLL. The dll exports a simple function. The header in the cpp file looks like
this
#ifdef TESTDLL2_EXPORTS
#define TESTDLL2_API __declspec(dllexport)
#else
#define TESTDLL2_API __declspec(dllimport)
#endif
extern "C" TESTDLL2_API int fnTestdll2(int x);
I'm trying to use this test dll from a VB app in which I have declared the function like so
Private Declare Function fnTestdll2 Lib "Testdll2" _
(ByVal val As Integer) As Integer
Whenever I try to use the function I get a runtime error '49' saying 'Bad calling convention'. I've tried changing the values to long and get the same result.
If I make the function void it works from the VB client if I use the function without passing a parameter. Does anyone know how to fix this?
-
February 8th, 2000, 10:51 AM
#2
Re: DLL Problem
Try changing the line :
>Private Declare Function fnTestdll2 Lib "Testdll2" _
>(ByVal val As Integer) As Integer
To :
Private Declare Function fnTestdll2 Lib "Testdll2" _
(ByVal val As Long) As Long
Chris Eastwood
CodeGuru - the website for developers
http://codeguru.developer.com/vb
-
February 8th, 2000, 10:51 AM
#3
Re: DLL Problem
whenever I write a C DLL for VB I do the following:
- use stdcall calling convention
- use a module definition file for all exported entries
- use "As Long" for all C "int"s
-
February 8th, 2000, 11:08 AM
#4
Re: DLL Problem
I've tried Private Declare Function fnTestdll2 Lib "Testdll2" _
(ByVal val As Long) As Long
and still get the same problem.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|