Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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);
like image 452
Joshua Gilman Avatar asked Feb 24 '14 01:02

Joshua Gilman


People also ask

What is app launch URI?

URIs allow you to launch another app to perform a specific task. This topic also provides an overview of the many URI schemes built into Windows. Learn how to register an app to become the default handler for a Uniform Resource Identifier (URI) scheme name.

What is a winform application?

Windows Forms (WinForms) is a free and open-source graphical (GUI) class library included as a part of Microsoft . NET, . NET Framework or Mono Framework, providing a platform to write client applications for desktop, laptop, and tablet PCs.

How do I run winform programs when my computer starts?

The Run key (And alternatively the RunOnce key for running your application once) will run all applications that are in it on startup/when a user logs on. This is the code I use in my applications, and it works great.


1 Answers

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);
like image 101
Leon Bambrick Avatar answered Sep 20 '22 19:09

Leon Bambrick