snowcrash09
snowcrash09

Reputation: 4804

How to obtain Windows special paths for a user account from a service

I want to be able to retrieve Windows "special paths" (e.g. temporary files folder, desktop) for user accounts, but from a service.

I know the normal way to do this is by using SHGetFolderPath with the appropriate CSIDL for the folder type. Is there any way to get this type of info for each user without the service having to log in as each user in turn?

Upvotes: 0

Views: 348

Answers (1)

Thomas
Thomas

Reputation: 181745

I'm no expert on this, but it seems you can use the hToken argument to SHGetFolderPath to pass in another user's token. I think you can create such a token using impersonation.

If that does not work: these folders are in the registry under HKEY_USERS/<user's-sid>/Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders. How to get the SID is explained in this question. It's in C# but I think it'll actually be easier in C++.

Upvotes: 1

Related Questions