如何开始从一个双赢8应用程序的程序? [英] How to start a Process from a Win 8 App?

查看:281
本文介绍了如何开始从一个双赢8应用程序的程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到的System.Diagnostics.Process启动一个新的进程。我想这是故意的。但是,有没有别的办法?这甚至可能?

解决方案
  

您可以使用在Windows 8 Metro应用此引用:<一href="http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/14e2be68-ef86-4480-a3fd-6ddf7ec7d1f1"相对=nofollow>如何启动一个外部程序从地铁应用。    所有Metro风格应用程序的高砂盒装环境中工作,没有办法直接启动外部应用程序。

您可以尝试使用启动类

  1. Launcher.LaunchFileAsync

      //路径在应用程序包中的文件启动
    字符串EXEFILE = @C:\ Program Files文件(x86)的\ APP.EXE;
    
    var文件=等待Windows.ApplicationModel.Package.Current.InstalledLocation
                            .GetFileAsync(EXEFILE);
    
    如果(文件!= NULL)
    {
        //设置选项来显示选择器
        VAR的选择=新Windows.System.LauncherOptions();
        options.DisplayApplicationPicker = TRUE;
    
        //启动检索文件
        布尔成功=等待Windows.System.Launcher.LaunchFileAsync(文件,选项);
        如果(成功)
        {
           //文件推出
        }
        其他
        {
           //文件启动失败
        }
    }
     

  2. Launcher.LaunchUriAsync

参考:<一href="http://social.msdn.microsoft.com/Forums/nl-NL/winappswithhtml5/thread/b38bb2de-2a05-4f7d-8547-48b9759d72d4"相对=nofollow>我可以使用Windows.System.Launcher.LauncherDefaultProgram(URI)来调用另外一个Metro风格的应用程序?

I can’t find System.Diagnostics.Process to start a new process. I guess this is on purpose. But is there a other way? Is this even possible?

解决方案

You can use this reference on Windows 8 Metro application : How to Start a external Program from Metro App. All the Metro-style applications work in the highly sand boxed environment and there is no way to directly start an external application.

You can try using Launcher class

  1. Launcher.LaunchFileAsync

    // Path to the file in the app package to launch
    string exeFile = @"C:\Program Files (x86)\App.exe";
    
    var file = await Windows.ApplicationModel.Package.Current.InstalledLocation
                            .GetFileAsync(exeFile);
    
    if (file != null)
    {
        // Set the option to show the picker
        var options = new Windows.System.LauncherOptions();
        options.DisplayApplicationPicker = true;
    
        // Launch the retrieved file
        bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
        if (success)
        {
           // File launched
        }
        else
        {
           // File launching failed
        }
    }
    

  2. Launcher.LaunchUriAsync

Reference: Can I use Windows.System.Launcher.LauncherDefaultProgram(Uri) to invoke another metro style app?

这篇关于如何开始从一个双赢8应用程序的程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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