|
-
January 17th, 2000, 10:26 AM
#1
Bad DLL Calling Convention, please help..
I'm not a VB Expert, but I would like to know what the hell is the error here.
My C++ DLL is declared this way:
extern "C" __declspec(dllexport) int PublishPDF(int Version, LPSTR source, LPSTR destination, int delai);
And my VB declare is:
private Declare Function PublishPDF Lib "PubPDF" (byval Version as Integer, byval Source as string, byval Destination as string, byval Delay as Integer) as Integer
And Visual Basic returns me a "bad calling convention" error (runtime error #49).. this is only happening at design time.
Thank you in advance, I'm lost here...!
---
Nicolas LeBlanc
Software Engineer
Ordiplan Inc.
-
January 18th, 2000, 02:24 AM
#2
Re: Bad DLL Calling Convention, please help..
2 things:
- you need to specify _stdcall calling convention
- you have to take into account, that in a 32 bit OS a C int is 4 Bytes, but a VB Integer is 2 bytes.
Thus change your VB declare from "AS Integer" to "As Long"
-
January 18th, 2000, 09:57 AM
#3
Re: Bad DLL Calling Convention, please help..
Yes, I added the stdcall but I noticed then my DLL wasn't working. And then I finally found the answer to my problems that nobody told me yet.
I'm going to write about it for people searching the messages to answers about this...
When you have a dll function that uses the "_stdcall", you *NEED* to declare this function into your .DEF file.. otherwise your function won't have an entry point. If you don't use the _stdcall, you will have access to your functions, but in Visual Basic, you'll have a bad calling convention.
I'm getting to learn about DLL just as they're being replaced by OCX ;-)
BTW, thanks for the 2 vs 4 bits integer, I didn't know about this one. I had one of my variables set as a long in VC++, what would that be then in VB?
---
Nicolas LeBlanc
Software Engineer
Ordiplan Inc.
-
January 18th, 2000, 10:01 AM
#4
Re: Bad DLL Calling Convention, please help..
>I had one of my variables set as a long in VC++, what would that be then in VB?
"...As Long" would be OK.
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
|