[英]Where can I create a directory without admin rights?
I am trying to create a directory with my program, but the program will not be run under admin.我试图用我的程序创建一个目录,但该程序不会在管理员下运行。 Where in the Windows file system can I create a directory and write to the directory without admin rights?我可以在 Windows 文件系统中的哪个位置创建目录并在没有管理员权限的情况下写入该目录?
Without admin permissions the intended behavior is that you can write to the folders inside the user account folder.没有管理员权限,预期行为是您可以写入用户帐户文件夹内的文件夹。
C:\\Users\\%USERNAME%\\ C:\\用户\\%USERNAME%\\
You can write to the documents, pictures and music sub folders, AppData\\Roaming or AppData\\Local\\ etc...您可以写入文档、图片和音乐子文件夹,AppData\\Roaming 或 AppData\\Local\\ 等...
As mentioned in the comments SHGetKnownFolderPath is the preferred method to get these folder paths, here is a simple example:正如评论中提到的SHGetKnownFolderPath是获取这些文件夹路径的首选方法,这里是一个简单的例子:
#include <windows.h>
#include <iostream>
#include <shlobj_core.h>
int main()
{
PWSTR path = nullptr;
SHGetKnownFolderPath(FOLDERID_Documents, 0, 0, &path);
std::cout << path << std::endl;
std::getchar();
return 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.