0

Hi my question is what is the best way to iterate through every standard directory location for every user on a computer using the win32 api (docs, music, pics etc) (or qt if possible). I have found these guys: SHGetKnownFolderPath GetProfilesDirectory GetUserProfileDirectory. The GetProfilesDirectory and GetUserProfileDirectory functions are obvious in how to use but don't return a path for the individual standard folders which could be a problem if I need to get a directory from a non-stanard location i.e. D:\Documents for a user whose profile directory is C:\Users\Josh. The SHGetKnownFolderPath function can do what I need it looks like however I don't know how to get an access token for a user not logged in. Is there any way to do what I want with the win32 api maybe with SHGetKnownFolderPath and access tokens for inactive users? Perhaps a third party library? I'm also using Qt but don't think that's relevant I couldn't find such libraries for Qt that do what I want...

Adrian McCarthy
  • 45,555
  • 16
  • 123
  • 175
riverofwind
  • 525
  • 4
  • 17
  • 1
    this paths stored in user registry hives. so for query it for inactive user you need first load user profile by *LoadUserProfile* and have token for user.. of course exist and undocumented way if you can not logon user and get it token - yourself enumerate profiles in registry, yourself load hives by *RegLoadKey* and finaly yourself parse registry data.. – RbMm May 14 '17 at 21:20
  • Thanks RbMm. *grumble* I was hoping there'd be a way to use SHGetKnownFolderPath. So there's no way to get a non-current user's access token? – riverofwind May 15 '17 at 19:58
  • but are you understand *for what/how* user token is used in *SHGetKnownFolderPath* ? for query *SID* from it and then open user key by this *SID* - `HKEY_USERS\SID\..` - so user profile **must** be loaded for use this function. however possible enumerate existing profiles directorys in known key, load user hive (*ntuser.dat*) if it yet not loaded and query paths from this hive. but here exist problems (not clear way) with synchronization.. – RbMm May 15 '17 at 20:05

0 Answers0