我试图列出C:\Windows\System32\config目录的文件。
我试过像这样使用QDir::entryList()
QDir dir(R"(C:\Windows\System32\config)");
dir.setFilter(QDir::Hidden | QDir::AllEntries | QDir::System | QDir::NoDotAndDotDot);
qDebug().noquote() << dir.entryInfoList();我也试过像这样使用std::filesystem::directory_iterator
std::string path = R"(C:\Windows\System32\config)";
for (const auto& entry : std::filesystem::directory_iterator(path))
{
qDebug().noquote() << entry.path().string().c_str();
}两者都给出了相同的输出:
C:\Windows\System32 32\config\ELAM
C:\Windows\System32 32\config\Journal
C:\Windows\System32 32\config\RegBack
C:\Windows\System32 32\config\systemprofile
C:\Windows\System32 32\config\TxR
文件管理器向我展示了以下输出:
C:\Windows\System32 32\config\BBI
C:\Windows\System32 32\config\BCD-模板
C:\Windows\System32 32\config\COMPONENTS
C:\Windows\System32 32\config\DEFAULT
C:\Windows\System32 32\config\驱动程序
C:\Windows\System32 32\config\ELAM
C:\Windows\System32 32\config\Journal
C:\Windows\System32\config\netlogon.ftl
C:\Windows\System32 32\config\RegBack
C:\Windows\System32 32\config\SAM
C:\Windows\System32 32\config\SECURITY
C:\Windows\System32 32\config\SOFTWARE
C:\Windows\SYSTEM 32\config\SYSTEM
C:\Windows\System32 32\config\systemprofile
C:\Windows\System32 32\config\TxR
C:\Windows\System32 32\config\VSMIDK
操作系统: Windows 10
问题是如何使用C++获得相同的输出?
发布于 2021-10-05 21:04:30
发布于 2019-12-16 16:48:49
这可能是权限问题,如果您在资源管理器的属性窗口中查看"Security“选项卡,您可能会看到一些文件在”用户“组上具有”读取“权限,但有些文件仅对”系统“和”管理员“具有权限。
当您在Windows中运行程序时,即使是从管理员帐户运行,它通常在没有提升的情况下运行,因此它将无法访问那些具有更多限制权限的文件。
ShellExecuteEx,如果需要,这将导致UAC弹出。https://stackoverflow.com/questions/59360532
复制相似问题