How do I launch a Windows Store application programmatically?

时间秒杀一切 提交于 2019-12-13 00:23:21

问题


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).

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".

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

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?


回答1:


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.



来源:https://stackoverflow.com/questions/17944718/how-do-i-launch-a-windows-store-application-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!