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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a C function in a DLL from VB

Status
Not open for further replies.

niel10

Programmer
Jul 13, 1999
2
IL
Please help me, I am having trouble calling a DLL function from VB.

This is the C function:

#define FT_RETCODE int
#define IN
#define OUT
typedef void *FT_HANDLE;

FT_DLL_INTERFACE
FT_RETCODE FT_createContext(
OUT FT_HANDLE *ftContext); /* dpFpFns context */
/* It returns a dpFpFns context

Return codes:
FT_OK all ok
Errors:
FT_ERR_NO_INIT fp software not initialized
FT_ERR_NO_MEMORY not enough memory available
*/

This is my declaration in VB:

Declare Function CreateContext Lib "dpFpFns.dll" Alias "FT_createContext" (ByVal Context As Long) As Long

This is how I am calling the function:

rc = CreateContext(VarPtr(test3))
[sig][/sig]
 
what exactly is the error? Can VB find the DLL? Can you set a break point in the DLL and does the execution reach it? Have you tried a C-stub (e.g. procedure with no arguments just to be sure execution reaches the entry point)? [sig][/sig]
 
I can find the DLL fine and two other functions I call work fine: FT_init() and FT_terminate()
The error I get is "Bad DLL calling convention"

I used to get problems where VB would not find the DLL and "Can't find entry point" but I overcame those problems.

How do I set a break point inside the DLL? What do I look for?

I think my problem is with the parameters but I'm not sure. If you are good with DLL functions I would GREATLY APPRECIATE your help. Would it help if I post the DLL and/or C header file?

E-mail: niel10@netvision.net.il
ICQ: 26678088
[sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top