473,386 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Inspecting the properties of shortcuts

Hello,

I've been asked to write a sort of "desktop clean-up" utility.

Requirements are simple: iterate through the shortcuts (*.lnk files) on the
currently logged-on user's desktop, and delete each link whose TargetPath
property no longer exists.

Iterating through the shortcuts on the desktop is easy enough using
Directory.GetFiles(*.lnk)

I found the following article which explains how to inspect the various
properties of a shortcut:
http://www.codeproject.com/useritems/Starter.asp

This uses COMInterop to inspect the shortcuts.

The author of the article says that he doesn't believe a managed solution is
available for this. Is this true?

I don't really have a problem using COMInterop but I guess I'd prefer to use
a managed solution if possible.

Does anyone know if there is one?

Thanks,

DJ
Jun 25 '07 #1
4 2466
David,

Well, there isn't a native managed wrapper for it if that is what you
mean, or a managed way to parse the files and get the contents.

COM interop is as managed as it is going to get.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"David Jackson" <so*****@somewhere.comwrote in message
news:u3*************@TK2MSFTNGP04.phx.gbl...
Hello,

I've been asked to write a sort of "desktop clean-up" utility.

Requirements are simple: iterate through the shortcuts (*.lnk files) on
the currently logged-on user's desktop, and delete each link whose
TargetPath property no longer exists.

Iterating through the shortcuts on the desktop is easy enough using
Directory.GetFiles(*.lnk)

I found the following article which explains how to inspect the various
properties of a shortcut:
http://www.codeproject.com/useritems/Starter.asp

This uses COMInterop to inspect the shortcuts.

The author of the article says that he doesn't believe a managed solution
is available for this. Is this true?

I don't really have a problem using COMInterop but I guess I'd prefer to
use a managed solution if possible.

Does anyone know if there is one?

Thanks,

DJ

Jun 25 '07 #2
Take a look at ShellLink component from ShellObjects at
http://www.ssware.com/shlobj/shlobj.htm


"David Jackson" <so*****@somewhere.comwrote in message
news:u3*************@TK2MSFTNGP04.phx.gbl...
Hello,

I've been asked to write a sort of "desktop clean-up" utility.

Requirements are simple: iterate through the shortcuts (*.lnk files) on
the currently logged-on user's desktop, and delete each link whose
TargetPath property no longer exists.

Iterating through the shortcuts on the desktop is easy enough using
Directory.GetFiles(*.lnk)

I found the following article which explains how to inspect the various
properties of a shortcut:
http://www.codeproject.com/useritems/Starter.asp

This uses COMInterop to inspect the shortcuts.

The author of the article says that he doesn't believe a managed solution
is available for this. Is this true?

I don't really have a problem using COMInterop but I guess I'd prefer to
use a managed solution if possible.

Does anyone know if there is one?

Thanks,

DJ

Jun 26 '07 #3
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:%2***************@TK2MSFTNGP06.phx.gbl...

Hi Nicholas,

Thanks for the reply
Well, there isn't a native managed wrapper for it if that is what you
mean, or a managed way to parse the files and get the contents.

COM interop is as managed as it is going to get.
OK.

DJ
Jun 26 '07 #4
"G Himangi" <in**@ssware.comwrote in message
news:u4*************@TK2MSFTNGP03.phx.gbl...

Hi G,

Thanks for the reply.
Take a look at ShellLink component from ShellObjects at
http://www.ssware.com/shlobj/shlobj.htm
That certainly does look like it would do the job, and a whole lot more!

However, as this is very much a "nice-to-have", I don't really think I can
justify the expense, even at $95.

Thanks again.

DJ
Jun 26 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: blabore | last post by:
I have a MDI windows forms application that uses a toolbar on the parent form. I've also setup a context menu on this form to be used as the dropdown menu for one of the toolbar buttons. However,...
0
by: Mark Broadbent | last post by:
Hope somebody could point me in the right direction. 1. I want to be able to drag and drop a file or a shortcut from a folder (from outside the app) and drop it on the apps form. 2. From this I...
0
by: GeorgeF | last post by:
How can I conditionally deploy shortcuts to my application? I have created a custom installer dialog box to give my users the option of creating desktop/start menu shortcuts, but the shortcuts do...
5
by: PAzevedo | last post by:
With ToolStripMenuItem objects i created a 'Tools' menu and from that menu droped an Item to which i assigned a ShortcutKey of 'Keys.Control | Keys.E', and the shortcut doesn't work. This...
4
by: garyusenet | last post by:
I want to write a quick and simple programme to update a shortcut on about 20 peoples workstations. They will all have the same shortcut, so I thought the simplest way would be to create the...
1
by: gwest | last post by:
I'm trying to read the properties on Windows Shortcuts such as the 'Target:', 'Run" and 'Target Type:'. DSOFile doesn't give access to these attributes (is it just for OLE files?). Anyone know...
331
by: Xah Lee | last post by:
http://xahlee.org/emacs/modernization.html ] The Modernization of Emacs ---------------------------------------- THE PROBLEM Emacs is a great editor. It is perhaps the most powerful and...
8
by: BD | last post by:
How can I duplicate the behavior of the operating system shortcut keys in my application? For example, my windows form has 5 controls (textboxes), the operating system will pickup which control...
2
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, you know how in the immediate window you can inspect an objects property, i was just wondering if there was a way to display all that on my web page in a div or something? thanks,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.