delphi 创建快捷方式_使用Delphi创建Internet快捷方式(.URL)文件

delphi 创建快捷方式

Unlike regular .LNK shortcuts (that point to a document or an application), Internet Shortcuts point to a URL (web document). Here's how to create a .URL file, or Internet Shortcut, using Delphi.

与常规.LNK快捷方式(指向文档或应用程序)不同,Internet快捷方式指向URL(网络文档)。 这是使用Delphi创建.URL文件或Internet快捷方式的方法。

The Internet Shortcut object is used to create shortcuts to Internet sites or web documents. Internet shortcuts are diverse from regular shortcuts (which contain data in a binary file) that point to a document or an application. Such text files with a .URL extension have their content in INI file format.

Internet快捷方式对象用于创建Internet站点或Web文档的快捷方式。 Internet快捷方式不同于指向文档或应用程序的常规快捷方式(其中的二进制文件中包含数据)。 具有.URL扩展名的此类文本文件的内容为INI文件格式。

The easiest way to look inside a .URL file is to open it inside Notepad. The content (in its simplest form) of an Internet Shortcut could look like this:

在.URL文件中查找的最简单方法是在Notepad中打开它。 Internet快捷方式的内容(以最简单的形式)如下所示:

As you can see, .URL files have an INI file format. The URL represents the address location of the page to load. It must specify a fully qualifying URL with the format protocol://server/page..

如您所见,.URL文件具有INI文件格式。 URL表示要加载的页面的地址位置。 它必须以格式protocol:// server / page 。指定一个完全限定的URL。

简单的Delphi函数创建一个.URL文件 ( Simple Delphi Function to Create an .URL File )

You can easily programmatically create an Internet shortcut if you have the URL of the page to which you want to link. When double-clicked, the default browser is launched and displays the site (or a web document) associated with the shortcut.

如果您具有要链接到的页面的URL,则可以轻松地以编程方式创建Internet快捷方式。 双击时,将启动默认浏览器,并显示与快捷方式关联的站点(或Web文档)。

Here's a simple Delphi function to create a .URL file. The CreateInterentShortcut procedure creates a URL shortcut file with the provided file name (FileName parameter) for the given URL (LocationURL), overwriting any existing Internet Shortcut with the same name.

这是创建.URL文件的简单Delphi函数 。 CreateInterentShortcut过程使用给定URL(LocationURL)的具有提供的文件名(FileName参数)的URL快捷方式文件,覆盖任何具有相同名称的现有Internet快捷方式。

Here's a sample usage:

这是一个示例用法:

A few notes:

一些注意事项:

  • You could save a web page as MHT (web archive) and then create a .URL shortcut to be able to access an offline version of a web document.

    您可以将网页另存为MHT (网络档案),然后创建.URL快捷方式以能够访问Web文档的脱机版本。

  • You must provide a full file name, along with the .URL extension, for the FileName parameter.

    您必须为FileName参数提供完整的文件名以及.URL扩展名。
  • If you already have an Internet Shortcut you are "interested in", you can easily extract the URL from an Internet Shortcut (.url) file.

    如果您已经对“ Internet快捷方式”感兴趣,则可以轻松地从Internet快捷方式(.url)文件中提取URL。

指定.URL图标 ( Specifying the .URL Icon )

One of the neater features of the .URL file format is that you can change the shortcut's associated icon. By default the .URL will carry the icon of the default browser. If you want to change the icon, you only have to add two additional fields to the .URL file, as in:

.URL文件格式的更简洁的功能之一是您可以更改快捷方式的关联图标。 默认情况下,.URL将带有默认浏览器的图标。 如果要更改图标,则只需向.URL文件添加两个其他字段,如下所示:

The IconIndex and IconFile fields let you specify the icon for the .URL shortcut. The IconFile could point to your application's exe file (IconIndex is the index of the icon as a resource inside the exe).

使用IconIndex和IconFile字段可以指定.URL快捷方式的图标。 IconFile可能指向您应用程序的exe文件(IconIndex是该图标作为exe内部资源的索引)。

Internet打开常规文档或应用程序的快捷方式 ( Internet Shortcut to Open a Regular Document or an Application )

Being called an Internet Shortcut, a .URL file format does not permit you to use it for something else—such as a standard application shortcut.

.URL文件格式被称为Internet快捷方式,不允许您将其用于其他用途(例如标准应用程序快捷方式)。

Note that the URL field must be specified in the protocol://server/page format. For example, you could create an Internet Shortcut icon on the Desktop that points to your program's exe file. You only need to specify the "file:///" for the protocol. When you double click on such a .URL file, your application will be executed. Here's an example of such an "Internet Shortcut":

请注意,URL字段必须以protocol:// server / page格式指定。 例如,您可以在桌面上创建一个指向程序的exe文件的Internet快捷方式图标。 您只需要为协议指定“ file:///”。 当您双击这样的.URL文件时,将执行您的应用程序。 这是此类“ Internet快捷方式”的示例:

Here's a procedure that places an Internet Shortcut on the Desktop, the shortcut points to the *current* application. You can use this code to create a shortcut to your program:

这是在桌面上放置Internet快捷方式的过程,该快捷方式指向* current *应用程序。 您可以使用以下代码创建程序的快捷方式:

Note: simply call "CreateSelfShortcut" to create a shortcut to your program on the Desktop.

注意:只需调用“ CreateSelfShortcut”即可在桌面上创建程序的快捷方式。

何时使用.URL ( When to Use .URL )

Those handy .URL files will be useful for virtually every project. When you create a setup for your applications, include a .URL shortcut inside the Start menu—let users have the most convenient way to visit your website for updates, examples, or help files.

这些方便的.URL文件实际上对每个项目都有用。 当您为应用程序创建设置时,请在“开始” 菜单中包含一个.URL快捷方式-让用户最方便地访问您的网站以获取更新,示例或帮助文件。

翻译自: https://www.thoughtco.com/create-internet-shortcut-url-file-delphi-1058130

delphi 创建快捷方式

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值