Solved

Get URL from an Internet Shortcut file

Posted on 2003-11-25
3
864 Views
Last Modified: 2006-11-17
I'm using VB.Net and I'm trying to get the URL for an Internet Shortcut given that I already have the filename. For example, I have a shortcut for http://www.yahoo.com stored on my computer as: c:\yahoo.url. When I right click the file in Windows Explorer and go to Properties, there's a property called "URL" listed. It's same URL that you get when you double-click the file. I've been playing around with the FileInfo class, but haven't had any luck.

Thanks, Zack Trainor
0
Comment
Question by:Ztrain2100
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
HappyParrot earned 250 total points
ID: 9831455
Those are called Shell links in MSDN terminology not shortcuts, that's why finding info on them can be frustraiting
There are two ways that I know of for accoplishing that task: using Windows Scripting Host and using Shell Namespace from shell32.dll
I'll explain the first one, becouse I've never used the second :)
1) All you need to do is add the windows scripting host as a reference for your project (Just select "add reference..." and then select WSH from the COM objects section) then on top of your class file add an import directive:
"Imports IWshRuntimeLibrary" (for VB)
2) Then you simply create a shell object like that:
Dim myShell as new WshShell()  (again VB)
3) Create Shortcut variable:
Dim myLink as WshURLShortcut=myShell.CreateShortcut("link.url")
(if its just a regular link use WshShortcut)
And that's it... you can now retrive your URL string from myLink.TargetPath
0
 

Author Comment

by:Ztrain2100
ID: 9833277
Thank you very much for your response. That worked just great!
0
 
LVL 2

Expert Comment

by:HappyParrot
ID: 9833361
Glad to be of assistance
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now