Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I get the owner of process running>
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2016
Network:
Windows Server 2016
Database:
Visual FoxPro
Application:
Desktop
Virtual environment:
VMWare
Divers
Thread ID:
01638970
Message ID:
01638985
Vues:
92
Maybe you should consider different approch https://www.levelextreme.com/Home/ShowHeader?Activator=17&ID=9807
>
>I need to get the owner of process that is running so that if they try and open another instance of the program it will not allow them to and kill that process.
>
>I can get the process and the current processID but my code will then kill all instances of the application effecting all users. I only want to prevent the user from opening a second instance.
>
>
>
>check Instance('myprog.exe')
>
>*----------------------------*
>FUNCTION CheckInstance()
>*----------------------------
>LPARAMETER ltProcess, ltKill
>
>oManager = GETOBJECT("winmgmts:")
>oStuff = oManager.InstancesOf("Win32_process")
>i = 0
>
>pnPID = GetProcessID()
>
>FOR EACH PROCESS IN oStuff
>   IF PROCESS.NAME = ltProcess
>      i = i + 1
>      IF pnPID <> PROCESS.ProcessId AND ltKill = .T.
>         PROCESS.TERMINATE()
>      ENDIF
>   ENDIF
>
>ENDFOR 
>
>RETURN i
>
>*----------------------------*
>FUNCTION GetProcessID()
>*----------------------------*
>* Identify the process id for the process
>DECLARE INTEGER GetCurrentProcessId IN kernel32
>pnPID = GetCurrentProcessId()
>
>RETURN pnPID 
>
>ENDFUNC
>
>
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform