gpt4 book ai didi

c++ - 在 windows shell 命名空间扩展下使用 _wopen()

转载 作者:行者123 更新时间:2023-11-28 02:54:56 25 4
gpt4 key购买 nike

我正在开发某种 Windows 外壳 namespace 扩展 (NE)。我的扩展程序为文件和文件夹提供自定义上下文菜单元素。除其他事项外,我需要在我的 NE 下创建一个新文件。我正在尝试创建一个文件,例如:

auto flags = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_CLOEXEC;
auto fd = _wopen(L"c:\\test.txt", flags , 0666);

我还尝试使用 "\\?\" 前缀:

auto flags = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_CLOEXEC;
auto fd = _wopen(L"\\\\?\\c:\\test.txt", flags , 0666);

无论如何,返回的文件描述符为负且错误号为 EACCES - 'Permission denied'我错过了什么?

最佳答案

用户不能在 C:\(没有提升)中创建文件。

shell 扩展使用当前用户的凭据运行,因此您不能在那里创建文件。

关于c++ - 在 windows shell 命名空间扩展下使用 _wopen(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22219300/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com