Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Retrieve shortcut(.lnk) target location

Retrieve shortcut(.lnk) target location

Scheduled Pinned Locked Moved C#
helpquestionworkspace
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    boshesh
    wrote on last edited by
    #1

    Dear all, I am trying to get the target location data a shortcut file on a desktop. I managed to get to the desktop using Environment.GetEnvironmentVariables() and can retrieve the shortcut file but can not find the way to retrieve the target location. Could anyone please help? Thank you!

    R 1 Reply Last reply
    0
    • B boshesh

      Dear all, I am trying to get the target location data a shortcut file on a desktop. I managed to get to the desktop using Environment.GetEnvironmentVariables() and can retrieve the shortcut file but can not find the way to retrieve the target location. Could anyone please help? Thank you!

      R Offline
      R Offline
      Robin Panther
      wrote on last edited by
      #2

      If you use Shell interface function CreateShortcut with name of existing link as argument - created WshShortcut object will be filled with shortcut information. sample: IWshShell ws = new IWshRuntimeLibrary.WshShell(); string shortcutFile = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) + "\\" + "ToDo.txt.lnk"; IWshShortcut sc = (IWshShortcut)ws.CreateShortcut(shortcutFile); after that sc.TargetPath will contain link target. Of course, if you have ToDo.txt shortcut on your desktop :). Don't forget to add reference to %system32%\\wshom.ocx and add "using IWshRuntimeLibrary;" Hope that helps. ____________________________________________ Robin Panther http://www.robinland.com

      B 1 Reply Last reply
      0
      • R Robin Panther

        If you use Shell interface function CreateShortcut with name of existing link as argument - created WshShortcut object will be filled with shortcut information. sample: IWshShell ws = new IWshRuntimeLibrary.WshShell(); string shortcutFile = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) + "\\" + "ToDo.txt.lnk"; IWshShortcut sc = (IWshShortcut)ws.CreateShortcut(shortcutFile); after that sc.TargetPath will contain link target. Of course, if you have ToDo.txt shortcut on your desktop :). Don't forget to add reference to %system32%\\wshom.ocx and add "using IWshRuntimeLibrary;" Hope that helps. ____________________________________________ Robin Panther http://www.robinland.com

        B Offline
        B Offline
        boshesh
        wrote on last edited by
        #3

        Thank you very much for your reply. The shortcut files already exist on the desktop so I just need to read? the file property to get the target location. I have looked at IWshShortcut before and only found how to create a shortcut file. Unless ws.CreateShortcut(shortcut) works for existing shortcut files too? Thank you ! -- modified at 3:25 Thursday 30th March, 2006

        B 1 Reply Last reply
        0
        • B boshesh

          Thank you very much for your reply. The shortcut files already exist on the desktop so I just need to read? the file property to get the target location. I have looked at IWshShortcut before and only found how to create a shortcut file. Unless ws.CreateShortcut(shortcut) works for existing shortcut files too? Thank you ! -- modified at 3:25 Thursday 30th March, 2006

          B Offline
          B Offline
          boshesh
          wrote on last edited by
          #4

          I think my mistake ;P (IWshShortcut)ws.CreateShortcut(shortcut) doesn't create a shortcut file on the desktop.... silly me. Thank you for your help!!! -- modified at 3:35 Thursday 30th March, 2006

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups