克服 Windows 7 shell MAX_PATH 限制
如果在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路径深度也不有限。
如何克服这一点?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
注册表有一种允许长路径的方法,在此url 。
I comes down to the following registry key:
In order to know your current value, you might do this:
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:
In order to know your current value, you might do this:
It is limited to Windows 10, Version 1607, and Later, but your question is about Windows 7.
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.