简体   繁体   中英

How do I get locale information about logged-in user from an administrator process on Windows XP in c++?

A similar question got asked by others here at least twice already (see links below) but never properly answered, perhaps because it wasn't put the right way. Let me have a go:

I have a process running under the local account on Windows and I need locale information about the user who is logged into the interactive session if there is one or any interactive session if there is more than one.

I need to know the user's language and country settings and it has to work on all kinds of Windows starting XP Service Pack 3.

I very much appreciate your answers!

The previous related questions that didn't really get answered:

I would do it in the following way:

  1. Enumerate logon sessions using LsaEnumerateLogonSessions
  2. Call LsaGetLogonSessionData to get logged on user SID identifier.
  3. Call ConvertSidToStringSid function to get a string representation of a sid.
  4. Look up registry setting HKEY_USERS[USER_SID_STRING]\\Control Panel\\International

This key has all sorts of information needed, and looks like all listed WINAPI finctions are available starting at Windows XP.

So this should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM