启动一个Metro风格的应用程序在桌面应用程序 [英] Launching a Desktop Application with a Metro-style app

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

问题描述

有没有在Windows 8推出从Metro风格应用程序的桌面应用程序的方法吗?我试图创建一些简单的快捷方式,桌面应用程序来代替开始屏幕上的桌面图标,这看出来的地方。

我只需要在C#中的东西超级简单,preferably,尽快打开一个应用程序的应用程序加载。我打算使这些快捷方式一些游戏,软件,等等,没有什么我做我自己。他们还只是供个人使用的,所以我可以使用应用程序的直接路径,如C:\\ Program Files文件(x86)的\\蒸汽\\ steamapps \\ COMMON \\天际\\ TESV.exe


解决方案

如果您只是想运行像(记事本,写字板,IE浏览器等)的桌面应用程序,然后通过的Process方法并的的ProcessStartInfo类

 尝试
{
//启动子进程。
    进程p =新的Process();
    //重定向子进程的输出流。
    p.StartInfo.UseShellExecute = FALSE;
    p.StartInfo.FileName =C:\\路径\\为\\ APP.EXE
    p.Start();
}

//实验2

  //使用的ProcessStartInfo类来开始新工艺,
//都以最小化模式。
无效OpenWithStartInfo()
{
    的ProcessStartInfo的StartInfo =新的ProcessStartInfo(IEXPLORE.EXE);
    startInfo.WindowStyle = ProcessWindowStyle.Minimized;    的Process.Start(StartInfo的);    startInfo.Arguments =www.northwindtraders.com;    的Process.Start(StartInfo的);
}


  

在Windows 8的Metro应用我发现这一点:<一href=\"http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/14e2be68-ef86-4480-a3fd-6ddf7ec7d1f1\">How启动一个
  外部程序从地铁应用。


  
  

所有的高砂Metro风格应用程序的工作盒装
  环境并没有办法直接启动外部
  应用程序。


  
  

您可以尝试使用启动类 - 取决于你需要它可能
  为您提供一个可行的解决方案。


检查:结果
<一href=\"http://social.msdn.microsoft.com/Forums/nl-NL/winappswithhtml5/thread/b38bb2de-2a05-4f7d-8547-48b9759d72d4\">Can我用Windows.System.Launcher.LauncherDefaultProgram(URI)来调用其他Metro风格的应用程序?

编号:的<一个href=\"http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloper$p$pviewgeneral/thread/e74cce2d-9a1f-4bf9-a5f2-733c15e4f297\">How从地铁应用程序内推出桌面应用?


  

地铁IE是一个特殊的应用程序。你不能援引Metro风格应用程序的可执行文件。


试试这个 - 我还没有测试,但还可能会帮助你。

<一个href=\"http://msdn.microsoft.com/en-us/library/windows/apps/hh701465.aspx#Y0\">Launcher.LaunchFileAsync

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

Is there a way to launch a desktop application from a Metro-style app on Windows 8? I'm trying to create some simple shortcuts to desktop applications to replace the desktop icons on the start screen, which look out of place.

I just need something super simple, preferably in C#, to open an application as soon as the app loads. I'm planning on making these shortcuts for some games, photoshop, etc, not anything I've made myself. They're also just for personal use, so I can use direct paths to applications like "C:\Program Files (x86)\Steam\steamapps\common\Skyrim\TESV.exe"

解决方案

If you simply want to run a desktop application like (notepad, wordpad, internet explorer etc) then go through Process Methods and ProcessStartInfo Class

try
{
// Start the child process.
    Process p = new Process();
    // Redirect the output stream of the child process.
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.FileName = "C:\Path\To\App.exe";
    p.Start();
}

// Exp 2

// Uses the ProcessStartInfo class to start new processes,
// both in a minimized mode.
void OpenWithStartInfo()
{
    ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
    startInfo.WindowStyle = ProcessWindowStyle.Minimized;

    Process.Start(startInfo);

    startInfo.Arguments = "www.northwindtraders.com";

    Process.Start(startInfo);
}

On Windows 8 Metro application i discovered this: 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 to use Launcher class – depends on your need it may provide you a feasible solution.

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

Ref: How to launch a Desktop app from within a Metro app?

Metro IE is a special app. You cannot invoke an executable from Metro style apps.

Try this - I have not test yet but may be it will help you..

Launcher.LaunchFileAsync

// Path to the file in the app package to launch
string exeFile = @"C:\Program Files (x86)\Steam\steamapps\common\Skyrim\TESV.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 launch failed
    }
}

这篇关于启动一个Metro风格的应用程序在桌面应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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