Reputation: 33
I'm looking for a way to get the desktop path of a specific user in c++. I googled it, and found heaps of anwers, but all of them (using SHGetFolderPath) give me the desktop path of the current user. I could get a list of users with NetUserEnum. Also, it would be great if it works on Windows 2000/XP but that's not necessary. Thanks ;)
#include <shlobj.h>
#include <stdio.h>
int main()
{
char path[MAX_PATH];
SHGetFolderPath(NULL,CSIDL_DESKTOP,NULL,SHGFP_TYPE_CURRENT,PATH);
printf(path);
return 0;
}
Upvotes: 1
Views: 1945
Reputation: 11
you can retrieve current user path via system environment constants
RUN -> CMD -> type "Set appdata"
the cmd will echo the path of application data folder then you can split this string
by "\" and get user path
i think this is the most easy way to do that
call cmd in c++ and pass the "set appdata" to it as parameter and get the output
then do what ever you want to retrieve current user path
Upvotes: 1