CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2004
    Posts
    3

    How to determine under which user account a process runs

    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

  2. #2
    Join Date
    Mar 2002
    Posts
    350

    Re: How to determine under which user account a process runs


  3. #3
    Join Date
    Sep 2004
    Location
    milano, italy
    Posts
    50

    Re: How to determine under which user account a process runs

    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:

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

  4. #4
    Join Date
    May 2004
    Location
    Pell City, Alabama
    Posts
    126

    Re: How to determine under which user account a process runs

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured