Protocol Handler with multiple paramters

时间:2017-03-14 10:22:08

标签: c# windows

I've set up a Protocol Handler in the registry and everything works fine. I can use the protocol and send a single parameter to a C# console app, great.

What I can't do however is have the C# app interpret the protocol data as multiple parameters. I've tried the following but have had no luck:

Protocol Link for MyProtocol = "C:\test.exe" "%1" "%2"

Call = MyProtocol://1 2

But all I get is one parameter with the 1, space character and the 2. What I need is to send multiple parameters, this would make my life easier.

If I have to just interpret the one parameter then fine, it's not the nicest way forward though.

1 个答案:

答案 0 :(得分:1)

你需要自己解析这个问题,协议处理程序定义了一个uri,它没有内在的知识,知道如何将多个参数传递给它所链接的可执行文件,所以你可以在protocolname:得到整个东西(包括MyProtocol://doathing/1/2)。

明显的格式为var uri = new Uri("MyProtocol://doAthing/1/2", UriKind.Absolute); if (uri.Scheme == "myprotocol") { if (uri.Authority == "doathing") { var argsArray = uri.PathAndQuery.Split(new [] {'/'}, StringSplitOptions.RemoveEmptyEntries); //... } }

您可以解析:

UriParser

或者实现自己的ALTER TABLE SalesOrderNumberLine ADD FOREIGN KEY (SalesOrderNumberID) REFERENCES SalesOrderNumber (ID) 子类。