user3365407
user3365407

Reputation: 111

C++ How to get current logged-on user name which is Microsoft Account?

In Windows 10 , user can use Microsoft Account to login , i know how to get offline user name but online user name can't.

How to get correct user name while user uses the Microsoft Account to login windows by C++ ?

Thanks!!

enter image description here

Upvotes: 0

Views: 558

Answers (1)

user2967540
user2967540

Reputation: 11

You can get "internet principal name" from NetUserGetInfo(...) function. with level 24.

pseudo code is :

if(NetUserGetInfo(NULL, sAccountName, 24, (LPBYTE*)&pInfo24) == NERR_Success)
{
    sPrincipalName = pInfo24->usri24_internet_principal_name;
}

Upvotes: 1

Related Questions