我有一个URI,它可以启动默认程序,现在我想知道如何从Windows Form应用程序中启动它。Google上的所有结果都使用Windows Apps API来启动URI,但我需要从表单中执行此操作。这应该怎么做?
以下是Apps版本:
System.Uri uri = new System.Uri("myprotocl://10.0.0.123");
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
我有一个URI,它可以启动默认程序,现在我想知道如何从Windows Form应用程序中启动它。Google上的所有结果都使用Windows Apps API来启动URI,但我需要从表单中执行此操作。这应该怎么做?
以下是Apps版本:
System.Uri uri = new System.Uri("myprotocl://10.0.0.123");
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
假设你的计算机已经为'myprotocl'注册了一个'handler',那么你可以通过将uri指定为进程的文件名来启动uri。
var url = "myprotocl://10.0.0.123";
var psi = new ProcessStartInfo();
psi.UseShellExecute = true;
psi.FileName = url;
Process.Start(psi);