Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the path of a Windows "special folder" for a specific user?

Inside a service, what is the best way to determine a special folder path (e.g., "My Documents") for a specific user? SHGetFolderPath allows you to pass in a token, so I am assuming there is some way to impersonate the user who's folder you are interested in.

Is there a way to do this based just on a username? If not, what is the minimum amount of information you need for the user account? I would rather not have to require the user's password.

(Here is a related question.)

like image 585
kgriffs Avatar asked Oct 13 '08 16:10

kgriffs


People also ask

How do I get to the Users folder in Windows?

Where is All User Folder in Windows 10/11? Your user files are stored on the C:/Users. You can click This PC to access your C drive. And choose your username to see folders like Pictures, Desktop, Downloads, Documents, and more.

What are special folders in Windows?

The system special folders are folders such as Program Files, Programs, System, or Startup, which contain common information. Special folders are set by default by the system, or explicitly by the user, when installing a version of Windows.


1 Answers

Please, do not go into the registry to find this information. That location might change in future versions of Windows. Use SHGetFolderPath instead.

http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx

Edit: It looks like LogonUser will provide the token for the other user that you need.

like image 178
Frederik Slijkerman Avatar answered Oct 05 '22 23:10

Frederik Slijkerman