How to obtain a special folder path for ANY user?
-
Hi all, I would like to know if there is a way to programmatically obtain the path to any user's any special folder? Here I do not mean "All users" profile but really for any user that has his/her profile created on the machine. For example, I can get what I need with the "SHGetSpecialFolderPath" function, but only for the current user. I need to do the same thing but for any arbitrary user. If this task can not be achieved with SHGetSpecialFolderPath function or any other API function, is there maybe some workaround (like manually reading specific registry keys and values)? Thanks in advance. Bila
-
Hi all, I would like to know if there is a way to programmatically obtain the path to any user's any special folder? Here I do not mean "All users" profile but really for any user that has his/her profile created on the machine. For example, I can get what I need with the "SHGetSpecialFolderPath" function, but only for the current user. I need to do the same thing but for any arbitrary user. If this task can not be achieved with SHGetSpecialFolderPath function or any other API function, is there maybe some workaround (like manually reading specific registry keys and values)? Thanks in advance. Bila
Bila1 wrote:
For example, I can get what I need with the "SHGetSpecialFolderPath" function, but only for the current user.
Use
SHGetFolderPath()
instead.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Bila1 wrote:
For example, I can get what I need with the "SHGetSpecialFolderPath" function, but only for the current user.
Use
SHGetFolderPath()
instead.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
Thanks for your reply. I have already tried this function, but I do not know how to use it to get what I need. I guess that the "hToken" parameter is the answer. Problem is, I do not know the process to create such a token (access token). Could you help me further with this issue please? Bila
-
Thanks for your reply. I have already tried this function, but I do not know how to use it to get what I need. I guess that the "hToken" parameter is the answer. Problem is, I do not know the process to create such a token (access token). Could you help me further with this issue please? Bila
Bila1 wrote:
I guess that the "hToken" parameter is the answer. Problem is, I do not know the process to create such a token (access token).
You can use
LogonUser()
to retrieve the token.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Bila1 wrote:
I guess that the "hToken" parameter is the answer. Problem is, I do not know the process to create such a token (access token).
You can use
LogonUser()
to retrieve the token.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Thanks, this sure helps. Now, one more twist: is there any other way I can do what I need -without- requiring the user's password?
You may read them under HKEY_USERS, but it is not suggested. Some keys are not created until the special folder path is requested by the user, and you may not have the permission to read these entries.
Regards Microsoft MVP in Visual C++ www.jiangsheng.net
-
Thanks, this sure helps. Now, one more twist: is there any other way I can do what I need -without- requiring the user's password?
Bila1 wrote:
...is there any other way I can do what I need -without- requiring the user's password?
Yes, but it's a bit more involved. You'll need to iterate through the folders in the following registry key: HKEY_USERS\xxxx\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders You'll need to loop through the users to find the right one (SID).
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
You may read them under HKEY_USERS, but it is not suggested. Some keys are not created until the special folder path is requested by the user, and you may not have the permission to read these entries.
Regards Microsoft MVP in Visual C++ www.jiangsheng.net
Hi, I already tried this approach but no success. Reason is that there are no keys in HKEY_USERS hive for any other users beside the current user and some system users (NETWORK SERVICE, LOCAL SERVICE if I remember correctly). If the problem is really with access permissions, is there a way to obtain them so I can read this hive? Maybe some workaround? Or for that reason, any other way at all to find out a special folder for any other user (I specifically need the startup folder)? Thanks. Bila -- modified at 3:56 Tuesday 24th October, 2006
-
Bila1 wrote:
...is there any other way I can do what I need -without- requiring the user's password?
Yes, but it's a bit more involved. You'll need to iterate through the folders in the following registry key: HKEY_USERS\xxxx\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders You'll need to loop through the users to find the right one (SID).
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb