Click to See Complete Forum and Search --> : How to determine under which user account a process runs


akon
November 10th, 2004, 07:18 AM
HI,

I enumerated all currently running processes with the psapi functions.
(enumprocesses, openprocess etc.)

I would like to know under which user account (System, userx...) a specific process is running.

I'm really new in microsoft world, so I din't find the right function call....



Best regards

Andre

AdaraCD
November 10th, 2004, 07:28 AM
http://www.codeguru.com/forum/showthread.php?t=277065

dolomighty
November 10th, 2004, 07:28 AM
you could access environment variables. under XP (so i think also 2K and NT) the variable is USERNAME.

with the C function getenv you can gain access to the env variables:


char uid[ 256 ];
strncpy( uid, getenv("USERNAME"), sizeof(uid));

Mutilated1
November 11th, 2004, 02:58 PM
no because that gives you the username who is logged on to the system, which is not necessarily the user who is running the specified process.

Look at the thread AdaraCD posted because he knows the correct answer.