克服 Windows 7 shell MAX_PATH 限制

发布于 2025-01-20 20:33:44 字数 982 浏览 0 评论 0 原文

如果在Windows注册表中存在启动某些可执行文件的上下文菜单键,并且提到了“%1” 命令行patrameter ploter Place持有人,则该可执行文件的路径可以超过 getCommandline() is仅限于 max_path ,在某些情况下,Windows试图将其简短的路径名淘汰。

示例:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\showpath\command]
@="\"C:\\Program Files (x86)\\Utilities\\COMLINE.EXE\" \"%1\""

当路径为:

"\\\\SERVER\MediaFilder25\Philosophic\20220407 Draft thoughts. Questions without answers on the background of the torn Internet\20220407-1 Draft thoughts. Questions without answers on the background of the torn Internet\20220407 Draft thoughts. Questions without answers on the background of the torn Internet.ysssss"

comline.exe将得到以下以下内容:

"\\\\SERVER\MediaFilder25\39FC~1\202204~3\202204~2\20220407 Draft thoughts. Questions without answers on the background of the torn Internet.ysssss"

如今 String 长度不限。 NTFS路径深度也不有限。

如何克服这一点?

If context menu key that launches some executable exists in Windows registry and the "%1" command line patrameter place holder is mentioned, the path this executable gets over GetCommandLine() is limited to MAX_PATH and in some cases Windows tries to make the short path name out of it.

Example:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\showpath\command]
@="\"C:\\Program Files (x86)\\Utilities\\COMLINE.EXE\" \"%1\""

When the path is:

"\\\\SERVER\MediaFilder25\Philosophic\20220407 Draft thoughts. Questions without answers on the background of the torn Internet\20220407-1 Draft thoughts. Questions without answers on the background of the torn Internet\20220407 Draft thoughts. Questions without answers on the background of the torn Internet.ysssss"

COMLINE.EXE will get following:

"\\\\SERVER\MediaFilder25\39FC~1\202204~3\202204~2\20220407 Draft thoughts. Questions without answers on the background of the torn Internet.ysssss"

Nowadays string length isn't limited. NTFS path depth isn't limited, too.

How to overcome this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

神爱温柔 2025-01-27 20:33:45

注册表有一种允许长路径的方法,在此url

I comes down to the following registry key:

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

In order to know your current value, you might do this:

reg query "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" | findstr "LongPathsEnabled"

It is limited to Windows 10, Version 1607, and Later, but your question is about Windows 7.

There is a way in registry to allow long paths, explained in this URL.

I comes down to the following registry key:

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

In order to know your current value, you might do this:

reg query "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" | findstr "LongPathsEnabled"

It is limited to Windows 10, Version 1607, and Later, but your question is about Windows 7.

热风软妹 2025-01-27 20:33:45

Windows 10 版本 1607 包含 api-ms-win-core-path-l1-1-0.dll。

有一个 api-ms-win-core-path-l1-1-0.dll 的副本版本,可以像 Windows 10 版本 1607 那样操作长路径。

源代码可在此处获取: https://github.com/nalexandru/ api-ms-win-core-path-HACK

在将平台工具集切换到 v110 后,我设法在 Visual Studio 2012 中编译它并成功测试它,例如,使用现在依赖于此 DLL 的 Python 3.9。

我认为,Windows 7 shell 无法利用开箱即用的 LongPathsEnabled 注册表参数,应用程序应该直接使用此 DLL(但在这种情况下 - 为什么要使用 DLL?我们可以构建正确的功能直接进入应用程序)。我的问题是 shell 是否可以利用它,答案是 - “还不能!”。这取决于shell本身。

Windows 10, Version 1607 contains api-ms-win-core-path-l1-1-0.dll.

There is a replica version of api-ms-win-core-path-l1-1-0.dll that can manipulate long paths the way the Windows 10, Version 1607 it does.

Source code is available here: https://github.com/nalexandru/api-ms-win-core-path-HACK

I managed to compile it in Visual Studio 2012 after switching platform toolset to v110 and tested it successfully, for example, with Python 3.9 that relies now on this DLL.

I think, Windows 7 shell can't take advantage of using LongPathsEnabled registry parameter out of the box, and applications should use this DLL directly (but in this case - why to use a DLL? we can build the proper function right into the application). My question was whether the shell can take advantage of it, and the answer is - "not yet!". It depends on shell itself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文