How can I get the SID of the current Windows account?

后端 未结 11 1140
面向向阳花
面向向阳花 2020-12-14 01:02

I am looking for an easy way to get the SID for the current Windows user account. I know I can do it through WMI, but I don\'t want to go that route.

Apologies to ev

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-14 01:41

    ATL::CAccessToken accessToken;
    ATL::CSid currentUserSid;
    if (accessToken.GetProcessToken(TOKEN_READ | TOKEN_QUERY) &&
        accessToken.GetUser(¤tUserSid))
        return currentUserSid.Sid();
    

提交回复
热议问题