Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check if VFP is running from Word ??
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00160586
Message ID:
00160816
Views:
24
>>>Hi,
>>>
>>>When in Word, I just want to know if VFP is running. I have tried to DECLARE FindWindowA and use it, but for it to work I need to specify the class of the main FoxPro window. When looking from another program the class is supposed to be 'FOX_400001' as I am using VFP3b, but this name doesn't do the trick.
>>>
>>>Is there some other was to find out if VFP is running or does anyone know the name the class of the FoxPro main window??
>>>
>>>
>>>Any help appreciated...
>>>
>>>
>>Hi Klas,
>>
>>If you pass a null string to FindWindow() as the class name all classes match. In this case, you should pass the caption of the window you're looking for. This, unfortunately, means that the caption must match the parameter exactly, including case. With windows with dynamic title text bars, this can be a problem.
>>
>>Try downloading my Is_Run32() function from the Win32 and other APIs section, here at the UT. Perhaps you can translate that into a VB script and use that.
>>
>>I highly discourage the use of class names with FindWindow(). VFP 3.0's are different from 5.0's and 6.0's are different from both.
>>
>>hth,
>
>Thanks for you efforts,
>
>I don't have a problem using FindWindow from VFP as I do not, as you said, have to specify the class. In VBA in Word on the other hand, it seems that the class have to be specified to make it work.
>
>The has to be some way to find out if an application as running as well as finding out if a window exists. Isn't there?

Not trivially. There's a dynamic registry hierarchy, HKEY_PERFORMANCE_DATA, which contains entries for all active threads an processes, but accessing it is fairly involved; enumerating the entries can be troublesome when threads and processes are started or stopped during the enumeration process.

I'm not certain if this is doable in VBA from Word, but you might try opening the VFP executable via low-level I/O for exclusive access; if VFP is running, Windows maintains an open file handle to the .EXE, which would cause the exclusive open to fail. This wouldn't help with a compiled VFP .EXE, since there, the compiled .EXE, and not VFP.EXE, is open.

In regular VB, passing a vbNullString, or an integer 0, in place of the ClassName, works to select all classes.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform