Get logged on user's name or email on Windows 8 using C++ and WinAPIs

后端 未结 1 1044
醉酒成梦
醉酒成梦 2021-01-28 22:21

On Windows 7 to retrieve the name of a logged on user I can do this:

LPTSTR pUserName = NULL;
DWORD dwcbSzUserName = 0;

//\'dwSessID\' = user session ID
if(WTSQ         


        
1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-28 23:05

    You could try NetUserGetInfo with USER_INFO_23 to get full name.

    Something basically like:

        //Got user name in 'pUserName'
        NetUserGetInfo(NULL, pUserName, 23, my_USER_INFO_23);
        //Got display name in my_USER_INFO_23.usri23_full_name
    

    0 讨论(0)
提交回复
热议问题