Home > front end >  How to enable "Long Path Aware" behavior for setting the current directory in a C window
How to enable "Long Path Aware" behavior for setting the current directory in a C window

Time:03-25

In a C console application on windows, i'm trying to break the Additional Manifest Files

The source code is very simple; it's also on enter image description here

To finish

i can only say that i don't know what else to test or if adding longPathAware element to the manifest is even possible with the type of application i'm trying to achieve that.

Maybe there's another api to change the current working folder of my application to a long path, and i would be fine with it, but at least _chdir and std::filesystem::current_path have the same limitations.

Workarounds

Using short names aka. 8.3 aliases might provide a limited work around.

For my cases this is often not feasible because short paths don't need to exists; they can be controlled system wide or per volume:

  • The general state can be queried with fsutil 8dot3name query
  • The per volume setting can be queried with fsutil behavior query disable8dot3 c:

Sidenotes

  • The manifest can be embedded in the executable or a dll.
    • It will be ignored when the dll containing it is delay loaded.
    • It will not be ignored by the delay loaded dll when the executable is containing it.
  • Because the Manifest is "additional" in the project settings, it doesn't need the assemblyIdentity element.

CodePudding user response:

The manifest applies to your application, it allows you to opt in to long path support.

However, long path support must also be enabled system wide. This is the group policy "Computer Configuration > Administrative Templates > System > Filesystem > Enable Win32 long paths".

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
"LongPathsEnabled"=dword:00000001

This design makes no sense but it is what it is. You can't argue that it is in the name of compatibility because one could create long paths with \\?\ since at least Windows 2000.

  • Related