Launching a Desktop Application with a Metro-style app(使用 Metro 风格应用程序启动桌面应用程序)
问题描述
有没有办法从 Windows 8 上的 Metro 风格应用程序启动桌面应用程序?我正在尝试为桌面应用程序创建一些简单的快捷方式,以替换开始屏幕上看起来不合适的桌面图标.
我只需要一些超级简单的东西,最好是在 C# 中,以便在应用程序加载后立即打开应用程序.我打算为一些游戏、photoshop 等制作这些快捷方式,而不是我自己制作的任何东西.它们也仅供个人使用,因此我可以使用诸如 "C:Program Files (x86)SteamsteamappscommonSkyrimTESV.exe"
如果您只是想运行桌面应用程序(如记事本、写字板、Internet Explorer 等),请通过 处理方法 和 ProcessStartInfo 类
试试{//启动子进程.进程 p = new Process();//重定向子进程的输出流.p.StartInfo.UseShellExecute = false;p.StartInfo.FileName = "C:PathToApp.exe";p.Start();}
//经验2
//使用 ProcessStartInfo 类启动新进程,//都处于最小化模式.无效的 OpenWithStartInfo(){ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");startInfo.WindowStyle = ProcessWindowStyle.Minimized;Process.Start(startInfo);startInfo.Arguments = "www.northwindtraders.com";Process.Start(startInfo);}
<块引用>
在 Windows 8 Metro 应用程序上,我发现了这个:如何开始Metro App 的外部程序.
所有 Metro 风格的应用程序都在高度沙盒中运行环境,没有办法直接启动外部应用.
您可以尝试使用 Launcher 类 –取决于你的需要它可能为您提供可行的解决方案.
检查一下:
我可以使用 Windows.System.Launcher.LauncherDefaultProgram(Uri) 来调用另一个 Metro 风格的应用程序?
参考: 如何从 Metro 应用程序中启动桌面应用程序?
<块引用>Metro IE 是一个特殊的应用程序.您不能从 Metro 风格应用调用可执行文件.
试试这个 - 我还没有测试,但它可能会帮助你..
Launcher.LaunchFileAsync
//要启动的应用包中文件的路径string exeFile = @"C:Program Files (x86)SteamsteamappscommonSkyrimTESV.exe";var 文件 = 等待 Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(exeFile);如果(文件!= null){//设置显示选择器的选项var options = new 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)SteamsteamappscommonSkyrimTESV.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:PathToApp.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)SteamsteamappscommonSkyrimTESV.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 风格应用程序启动桌面应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Metro 风格应用程序启动桌面应用程序
基础教程推荐
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01