简体   繁体   中英

C++ - How to get the desktop path OF A SPECIFIC USER

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;
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM