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

Call a DLL from FoxPro for Windows 2.6

Status
Not open for further replies.

sergiobotta

Programmer
May 2, 2014
5
UY
How can I do to call a DLL from FoxPro for Windows 2.6?

I read this post: where user "Gene77532" used SET LIBRARY TO FOXTOOLS with this commands: REG32, REGP
but it doesn´t work for me.
FoxPro says "REG32.PRG does not exist"

Thanks!
 
The functions in FoxTools that you're looking for are called RegFn and CallFn. Use RegFn to register the function and CallFn to call it.

I never used them, so I can't give you more than that, but it should get your started.

Tamar
 
As long as it is a 16 bit .DLL, you can most likely use it. I haven't been able to use a 32 bit .DLL without running into issues, but that's not to say it can't be done.
Anyway, there are several steps involved with calling an external .DLL with Fox, but here is a quick tutorial that may help.

First, you have to use foxtools to enable the functionality with:
SET LIBRARY TO foxtools
Then, you must also make availbale to Fox, whatever library you want to use. To do that, you also use SET LIBRARY TO. As an example:
SET LIBRARY TO SomeDLL.DLL

Then you have to declare each function within the .DLL you want to call to Fox, as well as define the parameters. There is a 3rd party library I use for serial communications, and in order to use a comm port it must first be opened. This is how I declare the 'OpenComm' function:
opencomm = regfn("OpenComm", "CII", "I")
where OpenComm is the function, "CII" are the (character, integer, integer) parameters passed TO the function, and the last "I" is the (integer) return value.

Next, you call the function using something like:
out_com = callfn(opencomm , 3, 100, 100)
where 3 is the comm port. 100 and 100 aren't important right now, but I believe they are the input and output buffer sizes. out_comm will contain the return value if the function completes successfully.




-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top