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. Windows Desktop Shortcut list

Windows Desktop Shortcut list

Scheduled Pinned Locked Moved C#
questiondatabase
2 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.
  • S Offline
    S Offline
    Stephen_Mc
    wrote on last edited by
    #1

    Hi all, I would like to get a list of Windows Desktop Shortcut's so I can build a list (with associated icons). How can I do this and display the icon and trigger the app when the link is selected? Thanks in advance. Stephen

    R 1 Reply Last reply
    0
    • S Stephen_Mc

      Hi all, I would like to get a list of Windows Desktop Shortcut's so I can build a list (with associated icons). How can I do this and display the icon and trigger the app when the link is selected? Thanks in advance. Stephen

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

      Probably you should get list of *.lnk files in desktop directory: DirectoryInfo di = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); FileInfo[] fi = di.GetFiles("*.lnk"); Keep in mind, that system links (My computer, My Documents) has no lnk file. Then, for each lnk file you should call shell function CreateShortcut: IWshRuntimeLibrary.WshShellClass ws = new IWshRuntimeLibrary.WshShellClass(); IWshRuntimeLibrary.IWshShortcut sc; for (int i = 0; i < fi.Length; i++) { sc = (IWshRuntimeLibrary.IWshShortcut)ws.CreateShortcut(fi[i].FullName); } Don't forget to add reference to %system32%\wshom.ocx. sc object will hold all information about link: sc.TargetPath - link target sc.Arguments - launch arguments sc.IconLocation - string, that could be used to get icon. These two articles could be helpful for icon extraction: Win32 .NET Hope it helps. ____________________________________________ Robin Panther http://www.robinland.com

      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