Allow launching applications from locations longer than 259

Here you can propose new features, make suggestions etc.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Allow launching applications from locations longer than 259

Post by *MarcinW »

Currently TC can't start applications from paths longer than 259 chars. It seems that this could be easily improved:

Code: Select all

if Win32Platform = VER_PLATFORM_WIN32_NT then
if Length(FileName) >= MAX_PATH then
  FileName:='\\?\'+FileName;

CreateProcess(PChar(FileName),...)
However, I don't know whether TC uses CreateProcess to launch applications or not.

Regards
User avatar
white
Power Member
Power Member
Posts: 5988
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Allow launching applications from locations longer than

Post by *white »

MarcinW wrote:However, I don't know whether TC uses CreateProcess to launch applications or not.
AFAIK TC uses ShellExecuteEx.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

AFAIK any Unicode API function supports prefixed paths up to 1023 characters. But is there any reason to keep applications in such deep places? Are you sure that app is able to work correctly in that place?
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

ShellExecuteEx doesn't support '\\?\' prefix, however TC could try something like this:

Code: Select all

if Length(FileName) < MAX_PATH then
  ShellExecuteEx(...)
else
if Win32Platform = VER_PLATFORM_WIN32_NT then
  CreateProcess(PChar('\\?\'+FileName),...) {This will work only for executable images}
If the launched file is not an executable, but for example a doc file, CreateProcess returns ERROR_BAD_EXE_FORMAT, so TC could display same error message as for the normal ShellExecuteEx call (ShellExecuteEx returns ERROR_PATH_NOT_FOUND in this case).

MVV wrote:AFAIK any Unicode API function supports prefixed paths up to 1023 characters.
According to my tests, under Windows NT family you can use both ANSI and Unicode APIs with '\\?\' prefix and they works. And MSDN says, that the limit is as large as 32767 chars (+ null) in this case. But this works only with some functions from kernel32.dll, which is a wrapper around ntdll.dll, which passes calls to kernel-mode. AFAIK in the kernel mode all paths use '\\?\' prefix, so such paths can also be passed directly from the user mode.

MVV wrote:But is there any reason to keep applications in such deep places? Are you sure that app is able to work correctly in that place?
I was waiting for this question :) I don't keep anything in such long locations, but sometimes I need/want to test something (for example if app is able to work correctly in that place ;)). Currently I must call CreateProcess to do this.


TC can use long paths almost everywhere, so this small improvement would be very nice.

Regards
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50873
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

TC has to use ShellExecuteEx to support elevation.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5988
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

Better error message than "Search path not found!" would be nice..
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

'Access denined' in my case. :)

BTW it is Explorer who shows really dumb message. :D 'Internet security settings don't allow to open one or more files' (approx., translated from Russian).

It seems that ShellExecute really doesn't support long paths.
Post Reply