如何在Windows系统上创建自己的别名(URL协议)?

13
你如何在Windows系统上创建自定义的名称(或URL协议)?
例子:
  • http:
  • mailto:
  • service:

Windows? COM/OLE的moniker(几乎)早于互联网。http协议处理程序不是com moniker。[com moniker的一个例子是“new:”](https://thrysoee.dk/InsideCOM+/ch11e.htm)。那在例如Win11中能行吗?[我非常确定会](https://www.vbsedit.com/html/a0d71def-47b9-4797-837c-bef653d958aa.asp)。 - Chef Gladiator
3个回答

4

您的注册链接包含了我所想要的细节。@Lasse的回答也包含了这些细节。 - Brett Veenstra

3
这是我们以前使用的 Delphi 代码,用于在 Web 应用程序中为用户创建快捷方式,以启动本地 Windows 程序。
procedure InstallIntoRegistry;
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_CLASSES_ROOT;
    if Reg.OpenKey('moniker', True) then
    begin
      Reg.WriteString('', 'URL:Name of moniker');
      Reg.WriteString('URL Protocol', '');
      Reg.WriteString('Source Filter', '{E436EBB6-524F-11CE-9F53-0020AF0BA770}');
      Reg.WriteInteger('EditFlags', 2);

      if Reg.OpenKey('shell\open\command', True) then
      begin
        Reg.WriteString('', '"' + ParamStr(0) + '" "%1"');
      end;
    end else begin
      MessageBox(0, 'You do not have the necessary access rights to complete this installation!' + Chr(13) +
        'Please make sure you are logged in with a user account with administrative rights!', 'Access denied', 0);
      Exit;
    end;
  finally
    FreeAndNil(Reg);
  end;

  MessageBox(0, 'Application WebStart has been installed successfully!', 'Installed', 0);
end;

0
Craig Brockschmidt的《Inside OLE》可能是关于moniker最好的覆盖范围。如果您想更深入地了解这个主题,我建议您购买这本书。如果您还有VS 6.0附带的MSDN光盘,它也包含在其中。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接