HighTechTalks DotNet Forums  

Get a shortcut target path

Dotnet Framework microsoft.public.dotnet.framework


Discuss Get a shortcut target path in the Dotnet Framework forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Paulo_Amaral
 
Posts: n/a

Default Get a shortcut target path - 10-11-2007 , 11:49 AM






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!

Reply With Quote
  #2  
Old   
Paulo_Amaral
 
Posts: n/a

Default RE: Get a shortcut target path - 10-11-2007 , 03:08 PM






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;
}



"Paulo_Amaral" wrote:

Quote:
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!

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.