监控自定义 Url 协议消息 - Delphi
Monitor a Custom Url Protocol Messages - Delphi
请某人举例说明我如何在我的 desktop-app 中处理来自网页的自定义 URL 协议,例如 zoom(你有一个 link,这会在 desktop-app)?
如果有人有很好的例子或他可以为此目的分享的东西,我会很高兴。
这是注册表项的问题。看看 Microsoft documentation.
下面的代码可以为您创建:
function RegisterURLProtocol(
const ProtocolID : String;
const ProtocolName : String;
const DefaultIcon : String;
const OpenCommand : String) : Boolean;
var
Reg : TRegistry;
begin
Result := FALSE;
Reg := TRegistry.Create(KEY_WRITE);
try
Reg.RootKey := HKEY_CLASSES_ROOT;
if not Reg.OpenKey(ProtocolID, TRUE) then
Exit;
Reg.WriteString('', 'URL:' + ProtocolName);
Reg.WriteString('URL Protocol', '');
if Reg.OpenKey('DefaultIcon', True) then begin
Reg.WriteString('', DefaultIcon);
end;
Reg.CloseKey;
if not Reg.OpenKey(ProtocolID + '\shell\open\command', True) then
Exit;
Reg.WriteString('', OpenCommand);
Result := TRUE;
finally
FreeAndNil(Reg);
end;
end;
请某人举例说明我如何在我的 desktop-app 中处理来自网页的自定义 URL 协议,例如 zoom(你有一个 link,这会在 desktop-app)?
如果有人有很好的例子或他可以为此目的分享的东西,我会很高兴。
这是注册表项的问题。看看 Microsoft documentation.
下面的代码可以为您创建:
function RegisterURLProtocol(
const ProtocolID : String;
const ProtocolName : String;
const DefaultIcon : String;
const OpenCommand : String) : Boolean;
var
Reg : TRegistry;
begin
Result := FALSE;
Reg := TRegistry.Create(KEY_WRITE);
try
Reg.RootKey := HKEY_CLASSES_ROOT;
if not Reg.OpenKey(ProtocolID, TRUE) then
Exit;
Reg.WriteString('', 'URL:' + ProtocolName);
Reg.WriteString('URL Protocol', '');
if Reg.OpenKey('DefaultIcon', True) then begin
Reg.WriteString('', DefaultIcon);
end;
Reg.CloseKey;
if not Reg.OpenKey(ProtocolID + '\shell\open\command', True) then
Exit;
Reg.WriteString('', OpenCommand);
Result := TRUE;
finally
FreeAndNil(Reg);
end;
end;