Is there a function in C PLUS Plus to know which programs are running on the other user?
like this:
tasklist /FI "IMAGENAME eq notbad.exe" /FI "USERNAME eq HWLONG"
HOWLONG = other user in my pc .
Last edited on
You say "which programs", but your example seems to ask whether HWLONG does run notbad.exe.
On a different* operating system I could ask:
pgrep -u HWLONG notbad
and answer would be "yes" if any pids are listed, while
ps ax -u HWLONG
lists all processes of that user.
*Different OS is a key point. The C++ is OS agnostic. If you want to do something OS-specific, like get info about processes, then you have to use tha API of the OS to get that info. That is, not call functions from C++ Standard Library, but from the OS.
its probably the 'right' ^^ way to do it, but
system("tasklist /v >somefile.txt"); will dump a snapshot that will be a half second or so out of date if you want a quick fix.. easy to parse out the info from there. There may be a way to get it without an intermediate file, not sure. Or if you can pipe the output of that into your program with a batch file or whatever?
thanks all so much , solved