Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining if an exe is being used.
Message
From
11/10/2007 16:00:31
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Miscellaneous
Thread ID:
01260393
Message ID:
01260419
Views:
12
>>Is there a way of determining if an exe is being used? The exe resides and is ran from a server.
>
>
>You can use LLFF FOPEN() to see if you can open the file for write access.
>
>
>nHandle = FOPEN("\\server\share\your.EXE",2)
>
>
>If nHandle is -1, it's running.
>
>Be sure to FCLOSE() it if you don't get an error or -1 on the FOPEN().

I'm not sure this would work, in the general case. It's not a requirement that, after you invoke an .EXE, the running process keeps its on-disk .EXE file open. It may be what actually happens with, say, a VFP .EXE but the OP didn't say what type of .EXE it is.

I'd think querying the list of running processes would be more reliable. For the local machine this shouldn't be too hard (parse the output of TASKLIST /SVC, there are probably myriad other more elegant ways). For a remote machine, more challenging. However, IIRC Hugo Ranea illustrated some way to do this via WMI, assuming the user has sufficient privileges or can input admin credentials in a RunAs.
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform