Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detect if a process is active
Message
De
10/06/2004 13:51:31
Dorin Vasilescu
ALL Trans Romania
Arad, Roumanie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00912120
Message ID:
00912340
Vues:
17
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)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform