Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling C++ dll

Status
Not open for further replies.

KingLouie

Programmer
Apr 12, 2002
11
CH
I want to call a dll created in c++.
in c++ it locks like this:

int open(LPCTSTR lpszFileName)
...
...

in vB:
Private Declare FileOpen Lib "c:\mydll.dll" Alias "open" (byval lpszFileName as String) as Long
...
a=FileOpen("c:\mifile.ixx")

At this point the runtime Error 49 appears ("Bad dll calling convention")

calling procedures whitout passing variabes works correctly

Tanx for any hint


 
The Line should read:

Private Declare Function FileOpen Lib "c:\mydll.dll" Alias "open" (byval lpszFileName as String) as Long

Since the DLL Code returns a Handle (int) to the OpenFile.

HTH


William
Software Engineer
ICQ No. 56047340
 
sorry this was a mistake but

Private Declare Function FileOpen Lib "c:\mydll.dll" Alias "open" (byval lpszFileName as String) as Long

still does not work
 
Well it may be that the FileOpen routine is expectine other parameters other than the file name. Have you checked this.
William
Software Engineer
ICQ No. 56047340
 
i'm at home now so i cant check. but tomorow i will check
thanx
 
Hey,

Maybe your Dll is using the _cdecl calling convention which VB has a problem. Check out article Q153586 at MSDN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top