Re: UserName of a process
- From: "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 8 Jul 2005 15:21:54 -0400
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
.
- Follow-Ups:
- Re: UserName of a process
- From: Prisy
- Re: UserName of a process
- References:
- UserName of a process
- From: Prisy
- UserName of a process
- Prev by Date: Re: Reading text of a Word doc or rtf file
- Next by Date: Re: please help exporting function!
- Previous by thread: Re: UserName of a process
- Next by thread: Re: UserName of a process
- Index(es):
Relevant Pages
|
|