Page 1 of 1

Adding External DLL Calls

Posted: Wed Aug 08, 2007 2:32 pm
by Jeff Barnes
Hi Everybody,

I have looked at many posts and am trying to add external DLL calls to my app.

Can someone please tell me where I am going wrong.


Syntax :
Function Connect() as String
Return values:
Success - Port number
Error - Empty String

DLL32 FUNCTION Connect() AS LPSTR PASCAL LIB "\Ez\dll\POx.DLL"



Syntax :
Function Handshake() as Boolean
Return values:
Success - TRUE
Error - FALSE

DLL32 FUNCTION Handshake() AS BOOL PASCAL LIB "\Ez\dll\POx.DLL"



Syntax :
Function SetID(id as String) as Boolean
Return values:
Success - TRUE
Error - FALSE

DLL32 FUNCTION SetID(ID AS LPSTR) AS WORD PASCAL LIB "\Ez\dll\POx.DLL"



Syntax :
Function SetTime( cur_time as Date) as Boolean
Return values:
Success - TRUE
Error - FALSE

DLL32 FUNCTION SetTime(cur_time AS Date) AS WORD PASCAL LIB "\Ez\dll\POx.DLL"



Syntax :
Function SetInterval(interval as Integer) as Boolean
Return values:
Success - TRUE
Error - FALSE

DLL32 FUNCTION SetInterval(interval AS LONG) AS WORD PASCAL LIB "\Ez\dll\POx.DLL"


Syntax :
Function GetData(data_array()) as integer
Return values:
Success - Number of Data lines
Error - 0

DLL32 FUNCTION GetData(data_array()) AS LONG PASCAL LIB "\Ez\dll\POx.DLL"

Thanks,
Jeff

Posted: Wed Aug 08, 2007 2:58 pm
by James Bott
Jeff,

Try it this way:

Code: Select all

local hPOX := LoadLibrary( "\ez\dll\POX.DLL" )

DLL32 FUNCTION ... LIB hPOX

...

FreeLibrary( hPOX )
James

Posted: Wed Aug 08, 2007 3:10 pm
by Jeff Barnes
Hi James,

When I try it that way and issue the Connect() command I get the following error:

Unrecoverable error 9003:
Too many recursive error handler calls

Posted: Wed Aug 08, 2007 4:01 pm
by James Bott
Jeff,

I'm not experienced with DLL32 calls, but I notice other working calls (in my notes) use the FROM clause and the same name as the function with a trailing "A" so you might try:

DLL32 FUNCTION Connect ... FROM "ConnectA" LIB hPOX

If that doesn't work, hopefully someone else with DLL experience will help.

James

Posted: Wed Aug 08, 2007 4:31 pm
by Jeff Barnes
Thanks for trying James ... Still no luck.

Re: Adding External DLL Calls

Posted: Wed Aug 08, 2007 6:32 pm
by Enrico Maria Giordano
Jeff Barnes wrote:Syntax :
Function Connect() as String
Return values:
Success - Port number
Error - Empty String

DLL32 FUNCTION Connect() AS LPSTR PASCAL LIB "\Ez\dll\POx.DLL"
As far as I know, you can't return a string from a DLL function. Do you have any VB samples?
Jeff Barnes wrote:Syntax :
Function SetID(id as String) as Boolean
Return values:
Success - TRUE
Error - FALSE

DLL32 FUNCTION SetID(ID AS LPSTR) AS WORD PASCAL LIB "\Ez\dll\POx.DLL"
AS BOOL instead of AS WORD.
Jeff Barnes wrote:DLL32 FUNCTION SetTime(cur_time AS Date) AS WORD PASCAL LIB "\Ez\dll\POx.DLL"
There's nothing like AS Date.
Jeff Barnes wrote:DLL32 FUNCTION GetData(data_array()) AS LONG PASCAL LIB "\Ez\dll\POx.DLL"
There's nothing like data_array() without data type.

EMG

Posted: Wed Aug 08, 2007 6:56 pm
by Jeff Barnes
Hi Enrico,

Please check your email.


Thanks,
Jeff