Foxtools functions

This forum is meant for questions about the Visual FoxPro Language support in X#.

Post Reply
b2k
Posts: 20
Joined: Thu Oct 06, 2022 5:53 pm
Location: USA

Foxtools functions

Post by b2k »

I am attempting to port a VFP application to X Sharp. In the application it is using the Foxtools library to check if the application is already running. There's got to be an easier way to do this, but I'm rusty on VFP and new to X Sharp, having spent the last 20 years developing web apps. I'm hoping someone can point me in the right direction.

Code: Select all

mGetWinTxt = RegFn("GetWindowText", "I@CI", "I")
mGetWindow = RegFn("GetWindow", "II", "I")
mIsWinVis =  RegFn("IsWindowVisible", "I", "I")

* Get the HWND (handle) to the main FoxPro window
foxhwnd = MAINHWND()
hwndNext = CallFn(mGetWindow,foxhwnd,0)
b2k
Posts: 20
Joined: Thu Oct 06, 2022 5:53 pm
Location: USA

Re: Foxtools functions

Post by b2k »

So this code was being used to check if the application was already running. I simply replaced that with a mutex.
Juraj
Posts: 164
Joined: Mon Jan 09, 2017 7:00 am

Re: Foxtools functions

Post by Juraj »

in Core dialect work this code:

Code: Select all

IF Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1
                MessageBox.Show("Aplikácia is launched.")
                Application.Current:Shutdown()
                RETURN
ENDIF  
Juraj
Last edited by robert on Wed Apr 09, 2025 6:54 am, edited 1 time in total.
Reason: formatted code snippet
mainhatten
Posts: 211
Joined: Wed Oct 09, 2019 6:51 pm

Re: Foxtools functions

Post by mainhatten »

As you mention yourself to be rusty in vfp:
AFAIR RegFN tries to register into the DOS 16 bit runtimes, the 32 bit equivalent was called RegFN32. It was used to call into Fll/Dll created by 16 or 32 bit compiler especially for Vfp3 or found on the DOS or NT based OS, as MS allowed via "thunking" to call into DLLs of the back then "other" bitted OS, as DOS supported the "extended" and "extended386" modes while NT/W2K still supported and ran DOS/16 Bit. If your OS runs in 64 bit mode, which was possible since XP and became the norm with Win7, those 16 bit OS Dll are not there. It does work for every 32 bit OS, even Windows 10 when installed as 32 bit, as you can run 16 Bit FPW or FPDos without a virtual machine there. If you were lucky sizes of both compilation environments were identical and the 16/32 bit divide did not crash.
In Vfp running on 32 or 64 bit OS it is better not to use RegFN/RegFN32 at all, but instead use the DECLARE DLL syntax, which also is easier to translate from googling other languages / examples from WINAPI. AFAIR Vfp6 was the last Vfp with official support for Dos based Win98/ME and I would not want to go back to those...
see https://hackfox.github.io/section4/s4g281.html

regards
thomas
Post Reply