简体   繁体   English

使用winform中的URI启动应用程序

[英]Launching an application with an URI from winform

I have a URI that launches a default program and I'm trying to figure out how to launch it from a Windows Form application. 我有一个启动默认程序的URI,我试图弄清楚如何从Windows窗体应用程序启动它。 All the results on Google are using the Windows Apps API to launch a URI, but I need to do it from a form. Google上的所有结果都使用Windows Apps API来启动URI,但我需要从表单中执行此操作。 How can this be done? 如何才能做到这一点?

Here is the Apps version: 这是应用程序版本:

System.Uri uri = new System.Uri("myprotocl://10.0.0.123");
var success = await Windows.System.Launcher.LaunchUriAsync(uri);

Assuming you have a 'handler' registered on your machine for 'myprotocl', you can launch a uri by specifying the uri as the filename of a process. 假设您的计算机上已为“myprotocl”注册了“处理程序”,则可以通过将uri指定为进程的文件名来启动uri。

var url = "myprotocl://10.0.0.123";
var psi = new ProcessStartInfo();
psi.UseShellExecute = true;
psi.FileName = url; 
Process.Start(psi);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM