Solved

Get URL from an Internet Shortcut file

Posted on 2003-11-25
3
863 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

919 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

17 Experts available now in Live!

Get 1:1 Help Now