SHGetFolderPath() for *another* user
-
I need to be able to find the special folders (e.g. My Documents) for a user other than the one currently logged on. The best I've been able to come up with so far is to use NetUserEnum() to get a list of all the users on the machine and check the HKEY_USERS\***\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders registry key (where *** is the user's SID). Peeking into the registry like this is a bit kludgy so is there a better way?
0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall. Awasu 2.2.4 [^]: A free RSS/Atom feed reader with support for Code Project.
-
I need to be able to find the special folders (e.g. My Documents) for a user other than the one currently logged on. The best I've been able to come up with so far is to use NetUserEnum() to get a list of all the users on the machine and check the HKEY_USERS\***\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders registry key (where *** is the user's SID). Peeking into the registry like this is a bit kludgy so is there a better way?
0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall. Awasu 2.2.4 [^]: A free RSS/Atom feed reader with support for Code Project.
-
Other way is, get the folders present in "C:\Documents and Settings\". 'Cuz each and every user account on the system has folders (of username) in this path.
Come online at:- jubinc@skype
Doesn't work on NT nor Vista. Doesn't work on non-English versions of Windows since that directory will be named differently. It also won't work if the special folders have been redirected to elsewhere.
0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall. Awasu 2.2.4 [^]: A free RSS/Atom feed reader with support for Code Project.
-
I need to be able to find the special folders (e.g. My Documents) for a user other than the one currently logged on. The best I've been able to come up with so far is to use NetUserEnum() to get a list of all the users on the machine and check the HKEY_USERS\***\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders registry key (where *** is the user's SID). Peeking into the registry like this is a bit kludgy so is there a better way?
0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall. Awasu 2.2.4 [^]: A free RSS/Atom feed reader with support for Code Project.
Taka Muraoka wrote:
I need to be able to find the special folders (e.g. My Documents) for a user other than the one currently logged on.
That's what the third argument to
SHGetFolderPath()
is for.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Taka Muraoka wrote:
I need to be able to find the special folders (e.g. My Documents) for a user other than the one currently logged on.
That's what the third argument to
SHGetFolderPath()
is for.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
DavidCrow wrote:
That's what the third argument to SHGetFolderPath() is for.
Doesn't work for me, unfortunately. You need the user's password to get a token.
0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall. Awasu 2.2.4 [^]: A free RSS/Atom feed reader with support for Code Project.
-
DavidCrow wrote:
That's what the third argument to SHGetFolderPath() is for.
Doesn't work for me, unfortunately. You need the user's password to get a token.
0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall. Awasu 2.2.4 [^]: A free RSS/Atom feed reader with support for Code Project.
Then just query the registry. For each user, query the following registry key: HKEY_USERS\<SID of user>\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Then just query the registry. For each user, query the following registry key: HKEY_USERS\<SID of user>\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
Well, that's what I wrote in my original post but it seems a bit of a clunky way of getting the info I need so I was just asking if there was a better way. Thanks anyway :-)
0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall. Awasu 2.2.4 [^]: A free RSS/Atom feed reader with support for Code Project.