Windows Installer and shortcuts

From: Keld Svendsen (ks_at_odin_net.dk)
Date: 10/30/03


Date: 30 Oct 2003 02:14:27 -0700

Using a standard way of accessing the target file (shown below) of a
shortcut (LNK file) does not work when the target program has been
installed by Windows Installer.

Any ideas?

Keld

PS. This code works on anything but links to programs installed by WI:

function GetTarget(const LinkFile:WideString):WideString;
var IU : IUnknown;
   SL : IShellLink;
   PF : IPersistFile;
   FindDate : TWin32FindData;
   TargetFile : array[0..MAX_PATH] of char;
begin
  IU := CreateComObject(CLSID_ShellLink);
  SL := IU as IShellLink;
  PF := SL as IPersistFile;
  PF.Load(PWideChar(LinkFile), STGM_READ);
  SL.Resolve(0, SLR_ANY_MATCH or SLR_NO_UI);
  SL.GetPath(TargetFile, MAX_PATH, FindDate, SLGP_UNCPRIORITY);
  result:=TargetFile;
end;