Hello,

What is the Win32 API to obtain current logged in user name or a special
unique ID without having to login as adminstrator


thank you

Re: Get current windows profile name by John

John
Tue Jun 06 06:35:51 CDT 2006

"semut" <ant_yio A_T hotmail D_O_T com> wrote in message
news:%23QzSiUViGHA.4512@TK2MSFTNGP02.phx.gbl
> Hello,
>
> What is the Win32 API to obtain current logged in user name or a
> special unique ID without having to login as adminstrator

GetUserName(Ex)

--
John Carson



Re: Get current windows profile name by ashwinrecwvm

ashwinrecwvm
Tue Jun 06 08:05:25 CDT 2006

I think this GetUserNameEx() will return the user name associated with
the calling thread.

If I am logged on as user X and start a process using run as cmd with
user Y and use this GetUserNameEx() then i will get Y as output.

How to get the logged on user( X in the above case) ??

can any one help me in this??

Thanks in advance
Ashwin



John Carson wrote:
> "semut" <ant_yio A_T hotmail D_O_T com> wrote in message
> news:%23QzSiUViGHA.4512@TK2MSFTNGP02.phx.gbl
> > Hello,
> >
> > What is the Win32 API to obtain current logged in user name or a
> > special unique ID without having to login as adminstrator
>
> GetUserName(Ex)
>
> --
> John Carson


Re: Get current windows profile name by Ben

Ben
Tue Jun 06 08:55:46 CDT 2006

<ashwinrecwvm@gmail.com> wrote in message
news:1149599125.890161.40710@g10g2000cwb.googlegroups.com...
>I think this GetUserNameEx() will return the user name associated with
> the calling thread.
>
> If I am logged on as user X and start a process using run as cmd with
> user Y and use this GetUserNameEx() then i will get Y as output.
>
> How to get the logged on user( X in the above case) ??

Perhaps in combination with RevertToSelf()?

>
> can any one help me in this??
>
> Thanks in advance
> Ashwin
>
>
>
> John Carson wrote:
>> "semut" <ant_yio A_T hotmail D_O_T com> wrote in message
>> news:%23QzSiUViGHA.4512@TK2MSFTNGP02.phx.gbl
>> > Hello,
>> >
>> > What is the Win32 API to obtain current logged in user name or a
>> > special unique ID without having to login as adminstrator
>>
>> GetUserName(Ex)
>>
>> --
>> John Carson
>



Re: Get current windows profile name by adebaene

adebaene
Wed Jun 07 02:21:43 CDT 2006


ashwinrecwvm@gmail.com a =E9crit :

> I think this GetUserNameEx() will return the user name associated with
> the calling thread.
>
> If I am logged on as user X and start a process using run as cmd with
> user Y and use this GetUserNameEx() then i will get Y as output.
>
> How to get the logged on user( X in the above case) ??

This questin doesn't make much sense in regard too Fast User Switching
and Remote Desktop (both ow which allow to have several users looged in
at the same time). Also, what if you "parent proces" is a service?

Perhaps what you're after is GetProcessWindowStation ->
GetUserObjectInformation(UOI_USER_SID), but you should you explain what
you are trying to achieve, so that we ma come up with a better
solution...

Arnaud
MVP - VC


Re: Get current windows profile name by ashwinrecwvm

ashwinrecwvm
Thu Jun 08 02:36:53 CDT 2006

Thanks for ur replies..

Actually my problem is with windows vista.
I log into vista machine with a non admin user account and try to
install some software.
Installation of this software writes some data to windows user profile.

But in vista, this installer asks for admin user's credentials. The non
admin user will provide some admin user's credentilas. Then this
installer will run under that admin users context and the installer
writes into the admin users profile.

I have to get the actual user who started the installation (Non admin
user in the above case).
adebaene@club-internet.fr wrote:
> ashwinrecwvm@gmail.com a =E9crit :
>
> > I think this GetUserNameEx() will return the user name associated with
> > the calling thread.
> >
> > If I am logged on as user X and start a process using run as cmd with
> > user Y and use this GetUserNameEx() then i will get Y as output.
> >
> > How to get the logged on user( X in the above case) ??
>
> This questin doesn't make much sense in regard too Fast User Switching
> and Remote Desktop (both ow which allow to have several users looged in
> at the same time). Also, what if you "parent proces" is a service?
>
> Perhaps what you're after is GetProcessWindowStation ->
> GetUserObjectInformation(UOI_USER_SID), but you should you explain what
> you are trying to achieve, so that we ma come up with a better
> solution...
>=20
> Arnaud
> MVP - VC