Solved

Get URL from an Internet Shortcut file

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

22 Experts available now in Live!

Get 1:1 Help Now