madshell.LoadShortCut returns wrong Path

delphi package - easy access to shell apis
Post Reply
kgulol
Posts: 9
Joined: Sat Jan 07, 2012 5:42 pm

madshell.LoadShortCut returns wrong Path

Post by kgulol »

ie :
try to load :

lnkFileName:='C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Oracle VM VirtualBox\Oracle VM VirtualBox.lnk';
ExeFileName:=madshell.LoadShortCut(lnkFileName).Path;


returns
"C:\Program Files (x86)\Oracle\VirtualBox\VirtualBox.exe"

but correct place is (right click to lnk file shows the correct path.)
"C:\Program Files\Oracle\VirtualBox\VirtualBox.exe"

how can I fix this bug on library?
or may you fix it for a newer version to publish ?

thank you so much again for this great library.
(OS:Win7 x64)
kgulol
Posts: 9
Joined: Sat Jan 07, 2012 5:42 pm

Re: madshell.LoadShortCut returns wrong Path

Post by kgulol »

interestingly
JvJVCLUtils.TargetFileName (from jedi)
also returns:
Program Files (x86)\....
instead of
Program Files\...

but shortcut targets me on "Program Files\..." directory.(install Virtualbox for x64.Check lnk file via right click properties. and ofsure nothing installed on x86 PRogram Files)

is Delphi problemmatic or its a windows API problem ?
what do you think ?
madshi
Site Admin
Posts: 10342
Joined: Sun Mar 21, 2004 5:25 pm

Re: madshell.LoadShortCut returns wrong Path

Post by madshi »

In madShell.pas in the function TIShortCut.GetPath please try adding the flag "SLGP_RAWPATH" to the last parameters of the "FShellLink.GetPath(...)" call. What do you get then? I suspect that the shortcut uses "%ProgramFiles%". If it does that, IShellLink.GetPath() will return different paths, depending on whether it's being called from a 32bit or 64bit application. The Explorer could be wrong just as much as madShell.
Post Reply