Get a shortcut target path

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

My question seens very simple: i want to write a function like
private string ResolveLink(string LinkFilePath) { ... }
that receives, for example, "c:\\myshortcut.lnk" and gives back the
shortcut's target path. Just the target's path.

Tks!
 
Found the solution:

Add the COM reference: Windows Script Host Object Model

Code:

using IWshRuntimeLibrary;

private string Resolve(string LnkFilePath)
{
WshShell shell = new WshShellClass();
IWshShortcut link = (IWshShortcut)shell.CreateShortcut(LnkFilePath);
return link.TargetPath;
}
 
Back
Top