Page 2 of 2

Posted: 2018-06-03, 14:09 UTC
by Dalai
Uh, this is not about Windows 10. I'm testing on XP (and Win2k where my Delphi is), because it's easier in this particular case.

OK, to summarize: TC 9.20 beta5 shows "Access denied" in its own error dialog (not the Windows one) when trying to launch FB-Traffic on XP - just like it did in previous betas/versions. My test program shows "%1 is not a valid Win32 application", similar to the Windows message when launching the file via TC's context menu. Logic tells me there is something different in TC, maybe FormatMessage doesn't get the message from the system or it's lost somewhere before it gets to the user. As I already said, I don't know what I can do to assist you.

Regards
Dalai

Posted: 2018-06-03, 20:54 UTC
by j7n
Thank you for looking into this issue I have also raised in the past.

I confirm that Beta 5 still doesn't display a correct error message on 2k/XP/2008/Seven for programs that require new subsystem version (increasingly common) or 64-bit machine. It now shows two lines of access denied instead of one like in the past.

Access denied!
"Access is denied."

For 64-bit binaries, x86 NT6.0 provides a helpful message that is a paragraph long (but not shown in TC).

"The version of this file is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need an x86..." (they could simplify and just tell the required version...)

Is it not possible to make double-click perform the same action as launching an exe from explorer/right-click with all error dialogs?

The double error reminds me of doors in video game Half-Life.

Posted: 2018-06-04, 15:07 UTC
by Dalai
j7n wrote:It now shows two lines of access denied instead of one like in the past.

Access denied!
"Access is denied."
This is done when TC's language differs from the OS language or the error message is potentially different. This should work for "simple" error texts that don't contain placeholders like %1, like the one you mentioned regarding x64 programs on 32 bit Windows.
For 64-bit binaries, x86 NT6.0 provides a helpful message that is a paragraph long (but not shown in TC).
Yes, that's another good test case which Ghisler can use. Apparently even that error text isn't shown by TC, because it also contains a placeholder:
Windows wrote:This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need a x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher.
Note that this error text slightly differs from the one shown by Explorer. Thus I searched where the error texts come from, and it looks like the FormatMessage function reads the error texts (in this case) from kernel32.dll(.mui), while Explorer reads it from shell32.dll(.mui).
Is it not possible to make double-click perform the same action as launching an exe from explorer/right-click with all error dialogs?
Well, the goal of this thread is that TC shows the same error text as Windows does, and with the suggested code it can be achieved. Ghisler just needs to find out what he does differently in TC. In the end, it's not the same action, but at least the end result (the error text) is the same.

Regards
Dalai

Posted: 2018-06-05, 07:45 UTC
by ghisler(Author)
It's probably because I'm not using GetLastError, but instead use the error returned in hInstApp:
If the function fails, it is set to an SE_ERR_XXX error value that indicates the cause of the failure.
I will try using GetLastError instead.

Posted: 2018-06-05, 14:14 UTC
by Dalai
Aha! Well, you could use both GetLastError and hInstApp, but as I see it, the latter only contains some generic error code that is not really helpful.

Regards
Dalai

Posted: 2018-06-06, 16:34 UTC
by ghisler(Author)
Yes indeed! In Beta 6, I'm now using GetLastError. Please let me know whether it makes any difference. I have also extended the buffer to 1024 characters.

Posted: 2018-06-06, 19:34 UTC
by j7n
The error message works now in all cases I tried (subsystem, x64, bad certificate). However, a literal "%1" is shown. Maybe you can replace it with the name of the exe file to make the text nicer for non-technical users.

Posted: 2018-06-06, 20:52 UTC
by Dalai
Ah, what a relief! Finally useful error texts in that message box, thank you!
j7n wrote:However, a literal "%1" is shown. Maybe you can replace it with the name of the exe file to make the text nicer for non-technical users.
I second that. @Ghisler: I guess that, if you don't want FormatMessage to handle that replacement, a simple StringReplace of %1 with the executable name would be enough. In other words, I wouldn't bother with placeholders starting from %2.

Regards
Dalai

Posted: 2018-06-07, 09:01 UTC
by ghisler(Author)
I will check it.

Posted: 2018-06-07, 09:44 UTC
by DrShark
It seems following may be related to the issue described here.
I treid to launch exe (c:\ProgramData\Microsoft\Windows\WER\ReportQueue\tc920x32_64_b3.exe) from a dir where NTFS rights don't allow this (at least here on Vista 32 bit) from TC 9.20 beta 6.
TC 9.20 beta 6 on Vista 32 bit still shows simple "Access denied" error:

Code: Select all

---------------------------
Total Commander
---------------------------
Access denied!



"Отказано в доступе."
---------------------------
ОК   
---------------------------
When to try to launch it from context menu, Windows shows following error:

Code: Select all

[Window Title]
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\tc920x32_64_b3.exe
[Content]
Отказано в доступе к указанному устройству, пути или файлу. Возможно,  у вас нет нужных прав доступа к этому объекту.

[ОК]

Posted: 2018-06-14, 11:14 UTC
by MarcinW
I can confirm that %1 is replaced with the executable name now :)

Posted: 2018-06-16, 10:09 UTC
by DrShark
For my sample case TC 9.20 RC1 now also shows file name in error window:

Code: Select all

---------------------------
Total Commander
---------------------------
Access denied on file
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\tc920x32_64_b3.exe!



"Отказано в доступе."
---------------------------
ОК   
---------------------------
but the error text is still different from one in Windows error window (see original post). Should it be like that?

Posted: 2018-06-16, 15:05 UTC
by Dalai
I can confirm DrShark's findings. Unfortunately, I don't know why this happens. Even my test program doesn't show anything more than "Access denied" when NTFS permissions don't allow the execution of executables. It seems that GetLastError doesn't help in finding the reason why the execution failed in such a case. I wonder what Explorer does beyond that ...

Regards
Dalai

Posted: 2018-06-16, 15:22 UTC
by j7n
The longer message doesn't provide more information. It just repeats the basic error in two long sentences. "Access is denied. Perhaps you don't have access rights." It gives an illusion of more information, but doesn't really say whether the access restriction is on the "device, path or file". I think the two words are sufficient if they aren't shown for the other cases that have nothing to do with "access".