首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用C++显示C:\Windows\System32 32\config的内容

使用C++显示C:\Windows\System32 32\config的内容
EN

Stack Overflow用户
提问于 2019-12-16 16:24:00
回答 2查看 493关注 0票数 0

我试图列出C:\Windows\System32\config目录的文件。

我试过像这样使用QDir::entryList()

代码语言:javascript
复制
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

代码语言:javascript
复制
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++获得相同的输出?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-10-05 21:04:30

一年零九个月后,我终于找到了解决办法。

当我尝试列表文件时,我正在构建一个32位的应用程序,并且进行了Wow64重定向。解决这个问题的方法有两种:

构建64位app

票数 0
EN

Stack Overflow用户

发布于 2019-12-16 16:48:49

这可能是权限问题,如果您在资源管理器的属性窗口中查看"Security“选项卡,您可能会看到一些文件在”用户“组上具有”读取“权限,但有些文件仅对”系统“和”管理员“具有权限。

当您在Windows中运行程序时,即使是从管理员帐户运行,它通常在没有提升的情况下运行,因此它将无法访问那些具有更多限制权限的文件。

  • 您可以显式地运行您的程序,例如右键单击exe/快捷方式和“以管理员身份运行”。请注意,在Visual中,您可以运行VS本身,因为您的程序总是需要运行提升,您可以将其设置为administrator.
  • If,在VS中,在"Linker“-> "Manifest File”中,有"UAC执行级别“选项,"highestAvailable”或"requireAdministrator“选项可能很有用。如果要启动子进程,则可以选择在这一点上提升它,例如使用ShellExecuteEx,如果需要,这将导致UAC弹出。
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59360532

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档