启动与WinForm的一个URI的应用 [英] Launching an application with an URI from winform

查看:301
本文介绍了启动与WinForm的一个URI的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个URI,启动一个默认的程序,我试图找出如何从一个Windows窗体应用程序启动。所有在谷歌结果使用Windows应用程序API推出一个URI,但我需要从表单做到这一点。如何才能做到这一点?



下面是应用程序版本:

 的System.Uri URI =新的System.Uri(myprotocl://10.0.0.123); 
VAR成功=等待Windows.System.Launcher.LaunchUriAsync(URI);


解决方案

假设你有一个'处理'您的计算机上注册对于myprotocl',你可以通过指定URI作为一个过程的文件名推出一个URI。

  VAR URL =myprotocl ://10.0.0.123; 
变种PSI =新的ProcessStartInfo();
psi.UseShellExecute = TRUE;
psi.FileName =网址;
的Process.Start(PSI);


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. All the results on Google are using the Windows Apps API to launch a URI, but I need to do it from a form. 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.

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

这篇关于启动与WinForm的一个URI的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆