Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FoxTools CallFN() Failing on Windows 10
Message
From
02/12/2015 17:34:36
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
FoxTools CallFN() Failing on Windows 10
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01628337
Message ID:
01628337
Views:
166
Likes (1)
This is a notice of a VFP incompatibility I recently found when run on Windows 10.

Some code required calling Win32API functions to get the user's current Screen DPI settings. One way to declare and call the required functions is via the DECLARE - DLL command. One code sample of how to do this is at http://www.spacefold.com/colin/posts/2005/12-01FONTMETRICandScreenD.html .

It is also possible to register, then call Windows API functions using the RegFN() (Register) and CallFN() (Call) functions of FoxTools.FLL. I inherited some code that used this technique. The following code works on Windows prior to version 10, but fails on Win10:
LOCAL lnRelease

* Register the Win32API ReleaseDC() function
* i.e. release the Device Context when finished with it:
m.lnRelease = RegFN( "ReleaseDC", "II", "I" )

* Call the function:
=CallFN( m.lnRelease, 0, m.lnHDC )  && fails on Win10 with "DdeReq failed C 4006"
The equivalent code using DECLARE - DLL is a bit simpler and easier to understand, and when declared and used that way the ReleaseDC() call does not fail on Win10.

I'm not sure when DECLARE - DLL was added to the language, before then it may have been necessary to use the FoxTools functions. In any case the solution seems to be to convert to DECLARE - DLL, at least for Windows 10 compatibility.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Next
Reply
Map
View

Click here to load this message in the networking platform