Re: UserName of a process
- From: "Prisy" <Prisy@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 8 Jul 2005 13:50:02 -0700
Nicholas,
I am trying to follow the steps you have mentioned. What do i have to import
in order to be able to use the methods like OpenProcessToken,
GetTokenInformation, etc...? I will be searching online as i wait for your
reply.
--
Thanks
Prisy
"Nicholas Paldino [.NET/C# MVP]" wrote:
> Prisy,
>
> In order to do that, you would have to get a handle to the process you
> want to get the username for first. Assuming you have that, you will have
> to do a bit of P/Invoke calls to get it.
>
> First, you would call OpenProcessToken. Once you have the token for the
> process, you would call GetTokenInformation passing the value TokenUser for
> the TokenInformationClass parameter. This will return a TOKEN_USER
> structure which contains the SID for the user that the process was launched
> under. The only field that the TOKEN_USER structure has is of type
> SID_AND_ATTRIBUTES, which has two fields, Sid and Attributes. The Sid field
> is the pointer to the SID. With that, you can call the LookupAccountSid
> function, passing the pointer to the SID and getting the domain and user
> that the process was started under.
>
> You should be able to find most of the definitions for these functions
> at http://www.pinvoke.net. If they are not there, post back, and we can
> help you with the definitions.
>
> Hope this helps.
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> "Prisy" <Prisy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:F91E3EDA-9A5B-4659-9C49-025DFDE3231D@xxxxxxxxxxxxxxxx
> > In asp.net(C#) we can get the Process Name of a process using the
> > following
> > code:
> >
> > System.Diagnostics.Process item;
> > item.ProcessName.ToString();
> >
> > Is there a way to get the User Name of a process?
> > --
> > Thanks
> > Prisy
>
>
>
.
- References:
- UserName of a process
- From: Prisy
- Re: UserName of a process
- From: Nicholas Paldino [.NET/C# MVP]
- UserName of a process
- Prev by Date: Re: Can i Box values in arrays
- Next by Date: Databound Combobox on TabControl hangs application
- Previous by thread: Re: UserName of a process
- Next by thread: Re: UserName of a process
- Index(es):
Relevant Pages
|