Launching an application with an URI from winform

社会主义新天地 提交于 2019-12-22 09:29:02

问题


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);

回答1:


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);


来源:https://stackoverflow.com/questions/21977144/launching-an-application-with-an-uri-from-winform

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!