Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
List of active processes with user
Message
 
 
To
28/06/2021 15:05:08
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
01681614
Message ID:
01681622
Views:
55
>>Someone can suggest me a way to retreive the list of current processes for the current user ? And not all ?
>>I found code for the list, but i have problems while retreiving the owner...
>>
>
>Michele,
>
>You may adjust to your needs / context:
>
>
>CLEAR
>
>LOCAL Me AS String
>
>m.Me = UPPER(STREXTRACT(SYS(0), " # ", ""))
>
>LOCAL WMIService, AllProcesses, Process
>LOCAL Owner AS String
>
>m.WMIService = GETOBJECT("winmgmts:\\.\root\cimv2")
>
>m.AllProcesses = m.WMIService.ExecQuery("SELECT * FROM Win32_Process",,48)
>
>FOR EACH m.Process IN m.AllProcesses
>
>	m.Owner = SPACE(1024)
>
>	TRY
>		IF m.Process.GetOwner(@m.Owner) == 0
>			IF UPPER(m.Owner) == M.Me
>				? TEXTMERGE("<<m.Process.Name>> is owned by the logged user (<<m.Process.ProcessId>>)")
>			ELSE
>				? TEXTMERGE("<<m.Process.Name>> is owned by <<m.Owner>>")
>			ENDIF
>		ENDIF
>	CATCH
>	ENDTRY
>
>ENDFOR
>
This code works fine.
Thanks.
Previous
Reply
Map
View

Click here to load this message in the networking platform