Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detect if a process is active
Message
From
10/06/2004 13:51:31
Dorin Vasilescu
ALL Trans Romania
Arad, Romania
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00912120
Message ID:
00912340
Views:
16
Thanks!

>>Hi all
>>I need to start an external utility program if is not already active. Is possible to detect this?
>>Or to forcefully stop it (is only used by my app)?
>>
>>TIA
>
>If you are using Windows XP, Windows 2000 Professional, Windows NT Workstation 4.0 SP4 and later, Windows Server 2003, Windows 2000 Server, Windows NT Server 4.0 SP4 and later then you can use WMI to check it (I put No error handling)
>
>
>
>? isRunning('MyProgram.Exe')
>
>Procedure isRunning(tcProcessID)
>
>local loLocator, loService, loProcesses, lnCount
>
>lnCount    = 0
>
>If Vartype(tcProcessID) = 'C' And Not Empty(tcProcessID)
>
>    loLocator       = createObject("wbemScripting.SwbemLocator")
>
>    loService       = loLocator.ConnectServer()
>
>    loProcesses     = loService.ExecQuery([SELECT * FROM Win32_Process WHERE Name = '] ;
>
>          + Alltrim(tcProcessID) + ['])
>
>    lnCount        = loProcesses.Count
>Endif
>
>Return lnCount > 0
>
>Endproc
>
>
>
>For terminating the program, see Message #890501 (You'll need XP or 2003 for Terminate is not implemented for the other versions)
Previous
Reply
Map
View

Click here to load this message in the networking platform