c++ - 如何通过 C++ 可执行文件中的 list 启用 "Long Path Aware"行为?

标签 c++ visual-studio visual-studio-2017 manifest long-filenames

我正在尝试关注 Microsoft documentation解除 Windows 10 下 API 中的 MAX_PATH 文件路径限制。它说:

You can also enable the new long path behavior per app via the manifest:

<application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
        <ws2:longPathAware>true</ws2:longPathAware>
    </windowsSettings>
</application>

所以,第一个问题。是否可以在 Visual Studio 2017 的项目属性中启用它?

第二个问题:我没有找到上面的答案,所以我决定走手动路线:

  1. 我创建了 additional.manifest 文本文件:

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
    <application xmlns="urn:schemas-microsoft-com:asm.v3">
        <windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
            <ws2:longPathAware>true</ws2:longPathAware>
        </windowsSettings>
    </application>
    </assembly>
    
  2. 然后我将它添加到项目属性中:

enter image description here

  1. 但是当我编译它时,它给了我这个警告,并且该 list 在应用程序运行时似乎没有任何效果:

1>additional.manifest : manifest authoring warning 81010002: Unrecognized Element "longPathAware" in namespace "http://schemas.microsoft.com/SMI/2016/WindowsSettings".

那我做错了什么?

最佳答案

没有。 Windows 桌面或控制台应用程序的 Visual Studio 2017 v15.9.4 项目属性中没有启用“长路径感知”的开关。

您上面链接的 Microsoft 文档说明如下:

Starting in Windows 10, version 1607, MAX_PATH limitations have been removed from common Win32 file and directory functions. However, you must opt-in to the new behavior.

确保针对您使用的配置和当前工具集针对 Windows 10 版本 1607 或更高版本的 Windows SDK。您至少需要 Windows SDK v10.0.14393.795。当前版本是 v10.0.17763.0。

您可以在项目属性的“常规”属性表中找到并更改目标 Windows SDK 版本和目标工具集。

旁注:在所有配置中激活整体配置更改。将属性表的配置选项更改为“所有配置”和“所有平台”,除非您专门针对某个平台进行更改。

关于c++ - 如何通过 C++ 可执行文件中的 list 启用 "Long Path Aware"行为?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53918205/

相关文章:

visual-studio - 如何在 Visual Studio 的输出窗口中隐藏异常类型?

c++ - 为什么位置不变性对 std::function 很重要?

c++ - 我从源代码构建的 SDL 库崩溃了!

.net - Visual Studio - 更改类时自动刷新类 View

.net - 有没有办法以编程方式提取接口(interface)?

visual-studio - 在 VS 2017 自定义项目系统中,如何在解决方案资源管理器中将项目项设为粗体?

c# - Visual Studio 扩展 : Custom Quick Action

node.js - 在 Visual Studio 2017 中更新 Node 版本

c++ - 最多 2 位数字

c++ - While 循环在 C++ 中执行得太早