How to start the desktop application from the Windows Store applications

This is a student asked me the question yesterday 'how to start Desktop Application Store App from Windows? 'That's a good question and has aroused my interest, to be honest, simply did never thought this situation, but the problem is really too interesting, the answer is:' there is indeed a way to start the desktop application from the Windows Store application, the focus is not hard ', then take a look at is how to achieve this demand.


       This is a student asked me the question yesterday 'how to start Desktop Application Store App from Windows? 'That's a good question and has aroused my interest, to be honest, simply did never thought this situation, but the problem is really too interesting, the answer is:' there is indeed a way to start the desktop application from the Windows Store application, the focus is not hard ', then take a look at is how to achieve this demand.

       At first I would like to talk about ways of thinking to this problem, the first thought is: 'how a Windows Store application market should start another Windows program? ', The answer is obvious, usually by URI or File Association to achieve. That being the case, Windows Marketplace application should be able to start the desktop application through the fishes in this way. Then I did an experiment, I marked mms in Metro IE: // test whether the protocol is able to start Windows Media Player, the results are correct start; so far, the answer is already clear, since the desktop Windows Media Player such an application can be started, other applications should be able to do it, so I started working test and verify their ideas are correct.

       The entire testing process is accomplished by:

       (1) do a Windows Forms Application as an object to be called, this program is only a picture Lable, but in order to make the start time can pass parameters, slightly modified something.

Program.cs

  1. static class Program  
  2. {              
  3.     [STAThread]  
  4.     static void Main(string[] args)  
  5.     {  
  6.         Application.EnableVisualStyles();  
  7.         Application.SetCompatibleTextRenderingDefault(false);  
  8.         Application.Run(new Form1(args));  
  9.     }  

   

Form1.cs

  1. public partial class Form1 : Form  
  2. {  
  3.     public Form1()  
  4.     {  
  5.           
  6.     }  
  7.     public Form1(string[] args)              
  8.     {  
  9.         InitializeComponent();  
  10.         each data = args [0] .Split ( ':' );  
  11.         if (data.Length > 1)  
  12.         {  
  13.             label1.Text = data[1];  
  14.         }  
  15.         else 
  16.         {  
  17.             label1.Text = "no args";  
  18.         }  
  19.     }  

    

       (2) Then I add a custom URI Protocol in the computer's registry, named callbill, refer to Registering an Application to a URI Scheme

2013-11-03_160439_thumb

       (3) Finally, add a Windows Store application project, put a Button on the UI, write the following event delegate function Button.Click

  1. async private void Button_Click(object sender, RoutedEventArgs e)  
  2. {  
  3.     string uriToLaunch = "callbill:Hello_Uri_Launcher";  
  4.     var result = await Windows.System.Launcher.LaunchUriAsync(new Uri(uriToLaunch ));             

        

       The final outcome of the implementation of the Windows Store application, press the Button

2013-11-03_161133

       As I talked about at the beginning it is as simple as a few easy steps to complete 'sounds very difficult' thing.





Original: Big Box  how to start the desktop application from the Windows Store applications


Guess you like

Origin www.cnblogs.com/chinatrump/p/11516537.html