wrong modulePath when symLink

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
Hurdet
Power Member
Power Member
Posts: 716
Joined: 2003-05-10, 18:02 UTC

wrong modulePath when symLink

Post by *Hurdet »

I have a file.exe in c:\test
compiled with:

Code: Select all

wchar_t modulePath[MAX_PATH];
GetModuleFileName(NULL, modulePath, MAX_PATH);
MessageBox(0, modulePath, 0, 0);
I create a symlink to c:\test\file.exe in d:\test2\file.exe
If I run d:\test2\file.exe from cmd I get same path d:\test2\file.exe
instead if I run same file from TotalCommander internal association I get c:\test\file.exe
Do it is a bug?
Last edited by Hurdet on 2023-07-09, 09:29 UTC, edited 1 time in total.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6973
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: wrong modulePath when symLink

Post by *Horst.Epp »

I don't understand.
For what reason do you need an TC internal association
to open a symlink ?
Windows 11 Home, Version 24H2 (OS Build 26100.4061)
TC 11.55 RC2 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.4 x64
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: wrong modulePath when symLink

Post by *ghisler(Author) »

The Windows function ShellExecuteEx seems to do this - I'm passing the link name to it, but it opens the link target. I have tried this with a target file test.docx and a link linkname.docx. It opens in LibreOffice here on Windows 11 and shows test.docx in the title. Even when I rename the link to linkname.txt, it opens in LibreOffice and shows test.docx in the title.
Author of Total Commander
https://www.ghisler.com
Hurdet
Power Member
Power Member
Posts: 716
Joined: 2003-05-10, 18:02 UTC

Re: wrong modulePath when symLink

Post by *Hurdet »

There is a lot of work to switch to CreateProcess?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: wrong modulePath when symLink

Post by *ghisler(Author) »

CreateProcess has its own shortcomings, like not working with elevation.
Author of Total Commander
https://www.ghisler.com
Post Reply