PhysiologyWeb Logo  Search
Share on Facebook Share on Twitter Share on LinkedIn Share on Pinterest Email Copy URL
PhysiologyWeb Loading...

Delphi Code - Create Internet Shortcut
Here is a simple Delphi function that saves an internet shortcut link in a specified folder. For additional Delphi code for the Windows operating system, see Useful Delphi Code for the Windows Operating System.
function CreateInternetShortcut(DestinationFolder, URL, URLShortcutName: String): Boolean;
var
Ini: TIniFile; //uses IniFiles unit
LinkPath: String;
begin
CreateInternetShortcut := False;

LinkPath := '';

LinkPath := DestinationFolder + '\' + URLShortcutName;
LinkPath := ChangeFileExt(LinkPath, '.url');

Ini := TIniFile.Create(LinkPath);
try
Ini.WriteString('InternetShortcut', 'URL', URL);
Ini.UpdateFile;
finally
Ini.Free;
end;

If FileExists(LinkPath) = True then CreateInternetShortcut := True else CreateInternetShortcut := False;
end;
The procedure below uses the function shown above to create the internet shortcut link.
procedure TForm1.Button1(Sender: TObject);
begin
CreateInternetShortcut('C:\PhysiologyWeb', 'https://www.physiologyweb.com/', 'PhysiologyWeb');
end;
Often, it is useful to save the shortcut on the Windows desktop or in some other special folder. To obtain the location of Windows special folders, please see Get the location for Windows special folders (e.g., desktop, start menu, program files, fonts, AppData, etc.).






Posted: Monday, September 4, 2023