Adding External DLL Calls

Adding External DLL Calls

Postby Jeff Barnes » Wed Aug 08, 2007 2:32 pm

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
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby James Bott » Wed Aug 08, 2007 2:58 pm

Jeff,

Try it this way:

Code: Select all  Expand view  RUN
local hPOX := LoadLibrary( "\ez\dll\POX.DLL" )

DLL32 FUNCTION ... LIB hPOX

...

FreeLibrary( hPOX )


James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Jeff Barnes » Wed Aug 08, 2007 3:10 pm

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
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby James Bott » Wed Aug 08, 2007 4:01 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Jeff Barnes » Wed Aug 08, 2007 4:31 pm

Thanks for trying James ... Still no luck.
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Adding External DLL Calls

Postby Enrico Maria Giordano » Wed Aug 08, 2007 6:32 pm

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
User avatar
Enrico Maria Giordano
 
Posts: 8716
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Jeff Barnes » Wed Aug 08, 2007 6:56 pm

Hi Enrico,

Please check your email.


Thanks,
Jeff
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Adding External DLL Calls

Postby vilian » Mon Nov 25, 2024 11:17 am

Good Morning Enrico,
Have you ever had success to use these functions with DATE parameters?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 978
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: Adding External DLL Calls

Postby Enrico Maria Giordano » Mon Nov 25, 2024 1:14 pm

No, you can't. You have to write a wrapper.
User avatar
Enrico Maria Giordano
 
Posts: 8716
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi and 59 guests