?
Solved

Get URL from an Internet Shortcut file

Posted on 2003-11-25
3
Medium Priority
?
880 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
HappyParrot earned 1000 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

650 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