PDA

View Full Version : Non-game programming question: Windows user name -> crazy user-specific registry key?


Larry Hastings
04-27-2006, 04:22 AM
I've been a Windows programmer for, oh, fifteen years now. But I've run into something that I don't know, I can't figure out, and I can't even figure out how to figure out. It's for a programming job I'm doing right now, not for my game, but I'm hoping someone here can help. It's on an apparently obscure topic, so I don't even know the name of the thing I'm asking for. Lemme describe it as best I know how.

If I look in my registry, using regedit, I see under HKEY_USERS a list of keys as follows:

.DEFAULT
S-1-5-18
S-1-5-19
S-1-5-19_Classes
S-1-5-20
S-1-5-20_Classes
S-1-5-21-612918248-21236....-1005 (digits elided for clarity)
S-1-5-21-612918248-21236....-1005_Classes (and again)

These are the actual storage for the per-user HKEY_CURRENT_USER information. The _Classes keys are used with RegOpenUserClassesRoot(), to provide per-user HKEY_CLASSES_ROOT information. The last two, the ones that starts with S-1-5-21-..., are for my user account, "lch". (I'm guessing .DEFAULT contains the "default" per-user information here, and this key would be copied to a new key if I created a new user on this PC.)

My question is: Given the current user, or (preferably) any user, how can a Win32 program determine this "S-1-5-21-..." string? How can I take "lch" and produce "S-1-5-21-..."? And what's it called, anyway?

I've seen some programs which use this string, this thing starting with S-1-5-21-..., to identify settings for me. So I am sure this string is somehow derivable for programs.


Thanks,

mahlzeit
04-27-2006, 04:47 AM
A google for "S-1-5-21-" gives at least these articles:
http://www.windowsitpro.com/Article/ArticleID/14781/14781.html
http://support.microsoft.com/kb/q154599/

Apparently, these IDs are listed under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList

svero
04-27-2006, 05:21 AM
I've been a Windows programmer for, oh, fifteen years now. But I've run into something that I don't know, I can't figure out, and I can't even figure out how to figure out.

Yep.. that sounds like the windows API alright :-)

Larry Hastings
04-27-2006, 06:01 AM
A google for "S-1-5-21-" gives at least these articles:
D'oh! I should have tried that. Thanks for your help!