Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3237018
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:41:20+00:00 2026-05-17T17:41:20+00:00

I want to get the user name who has launched the given application. For

  • 0

I want to get the user name who has launched the given application. For Example if Outlook or IE is launched I need to get the Name of the user who has launched it. This should be generic across all Windows OS . But the solution given below is failing in Windows 2003 user ,in both ADMIN and Standard User.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:41:21+00:00Added an answer on May 17, 2026 at 5:41 pm

    I found this page which gives a function to recover a process owner’s name.

    Here is the code (not my code and I couldn’t test it):

    bool ExtractProcessOwner( HANDLE hProcess_i,
                              CString& csOwner_o )
    {
       // Get process token
       HANDLE hProcessToken = NULL;
       if ( !::OpenProcessToken( hProcess_i, TOKEN_READ, &hProcessToken ) || !hProcessToken )
       {
          return false;
       }
    
       // First get size needed, TokenUser indicates we want user information from given token
       DWORD dwProcessTokenInfoAllocSize = 0;
       ::GetTokenInformation(hProcessToken, TokenUser, NULL, 0, &dwProcessTokenInfoAllocSize);
    
       // Call should have failed due to zero-length buffer.
       if( ::GetLastError() == ERROR_INSUFFICIENT_BUFFER )
       {
          // Allocate buffer for user information in the token.
          PTOKEN_USER pUserToken = reinterpret_cast<ptoken_user>( new BYTE[dwProcessTokenInfoAllocSize] );
          if (pUserToken != NULL)
          {
             // Now get user information in the allocated buffer
             if (::GetTokenInformation( hProcessToken, TokenUser, pUserToken, dwProcessTokenInfoAllocSize, &dwProcessTokenInfoAllocSize ))
             {
                // Some vars that we may need
                SID_NAME_USE   snuSIDNameUse;
                TCHAR          szUser[MAX_PATH] = { 0 };
                DWORD          dwUserNameLength = MAX_PATH;
                TCHAR          szDomain[MAX_PATH] = { 0 };
                DWORD          dwDomainNameLength = MAX_PATH;
    
                // Retrieve user name and domain name based on user's SID.
                if ( ::LookupAccountSid( NULL,
                                         pUserToken->User.Sid,
                                         szUser,
                                         &dwUserNameLength,
                                         szDomain,
                                         &dwDomainNameLength,
                                         &snuSIDNameUse ))
                {
                   // Prepare user name string
                   csOwner_o = _T("\\\\");
                   csOwner_o += szDomain;
                   csOwner_o += _T("\\");
                   csOwner_o += szUser;
    
                   // We are done!
                   CloseHandle( hProcessToken );
                   delete [] pUserToken;
    
                   // We succeeded
                   return true;
                }//End if
             }// End if
    
             delete [] pUserToken;
          }// End if
       }// End if
    
       CloseHandle( hProcessToken );
    
       // Oops trouble
       return false;
    }// End GetProcessOwner
    

    Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to get the user who login now .. how to do this
If I want to get a user that has the email address of 'me@example.com',
I want to get 100 and example from this string ?connect:100/username:example/ I searched in
I want to get the user mail address, as shown in this thread :
I want to get the user ID of a given process ID using C
I am trying to get the username of the user who has the blog
I'm trying to get to grips with web2py/python. I want to get the user
I want to get the following information of a user that is captured using
i want to get the full address of user programatically using c# how can
I want to get the home directory of a user of a unix system.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.