如何以编程方式启动 Windows 应用商店应用程序? [英] How do I launch a Windows Store application programmatically?

查看:43
本文介绍了如何以编程方式启动 Windows 应用商店应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚构建了 Visual Studio 2012 提供的项目模板之一(可通过模板"->其他语言"->Visual C#"->Windows 应用商店"访问新项目"对话框中的拆分应用程序 (XAML)"模板).

I just built one of the project templates Visual Studio 2012 offers (the 'Split App (XAML)' template accessible via Templates -> Other Languages -> Visual C# -> Windows Store in the 'New Project' dialog).

我可以从 Visual Studio 2012 执行应用程序,我可以从 Windows 8 开始屏幕启动它 - 但是如果我尝试直接启动生成的可执行文件(例如通过 Windows 资源管理器或从命令外壳),一个完整的- 打印屏幕错误消息说此应用程序无法在您的 PC 上运行".

I can execute the application from Visual Studio 2012, and I can launch it from the Windows 8 start screen - but if I attempt to launch the generated executable directly (e.g. via the Windows explorer or from a command shell), a full-screen error message is printed saying "This app can't run on your PC".

通过 Process Explorer 查看正在运行的应用程序实例表明它 a) 只是链接到 .NET 运行时 MSCOREE.DLL 并且 b) 它被这样的命令行调用:

Looking at a running instance of the application via Process Explorer shows that it a) just links against the .NET runtime MSCOREE.DLL and b) it gets invoked with a command line like this:

"[..] \bin\Debug\AppX\WindowsStoreSample.exe" -ServerName:App.AppXgsxd2athqtr03f55we0938hcn632we3k.mca

我的实际问题是:以编程方式启动此类应用程序的正确方法是什么?我会使用普通的 CreateProcess 然后尝试组装如上所示的命令行吗?如果是这样,我如何确定正确的 -ServerName 参数?或者是否有其他方式来启动此类应用程序?

My actual question is: what's the correct way to launch this kind of application programmatically? Would I use plain CreateProcess and then try to assemble a command line like shown above? If so, how could I determine the correct -ServerName argument? Or is there some other way to launch such applications?

推荐答案

启动 Windows 应用商店应用的正确方法是使用 IApplicationActivationManager 界面.这也是 Visual Studio 本身用于启动应用程序的内容.接口上的所有方法都有一个 DWORD 输出参数,用于获取新启动进程的 PID.

The correct way to launch Windows Store apps is to use the IApplicationActivationManager interface. This is also what Visual Studio itself uses for launching the application. All methods on the interface have a DWORD out parameter which gets you the PID of the newly launched process.

这篇关于如何以编程方式启动 Windows 应用商店应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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