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

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

By , About.com Guide

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")

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. 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.