1. Home
  2. Computing & Technology
  3. Delphi Programming

How to extract the URL from an Internet Shortcut (.url) file

By Zarko Gajic, About.com

Internet shortcuts are diverse from regular shortcuts that point to a document or an application. Such text files with a .url extension have their content in INI file format.
Here's a sample content of an Internet Shortcut file:

[InternetShortcut]
URL=http://delphi.about.com

Here's how to read the URL from an Internet Shortcut file using Delphi code:

~~~~~~~~~~~~~~~~~~~~~~~~~
uses iniFiles;

function URLFromShortcut(const dotURL: string): string;
begin
   with TIniFile.Create(dotURL) do
   try
     try
       Result := ReadString('InternetShortcut', 'URL', '') ;
     except;
       Result := '';
     end;
   finally
     Free;
   end;
end;

//Usage
var URL : string;
URL := URLFromShortcut('c:\myshortcut.url') ;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» How to create a thumbnail image from a stream
« How to change the web form's enctype attribute (to "multipart/form-data")

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2004 Delphi Tips
  7. How to extract the URL from an Internet Shortcut (.url) file

©2009 About.com, a part of The New York Times Company.

All rights reserved.