csharp C#中启动Metro应用
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp C#中启动Metro应用相关的知识,希望对你有一定的参考价值。
#region LaunchMetroApp
private enum ActivateOptions
{
None = 0x00000000,
DesignMode = 0x00000001,
NoErrorUI = 0x00000002,
NoSplashScreen = 0x00000004
}
[ComImport, Guid("2e941141-7f97-4756-ba1d-9decde894a3d"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
private interface IApplicationActivationManager
{
IntPtr ActivateApplication([In] String appUserModelId, [In] String arguments, [In] ActivateOptions options, [Out] out UInt32 processId);
IntPtr ActivateForFile([In] String appUserModelId, [In] IntPtr itemArray, [In] String verb, [Out] out UInt32 processId);
IntPtr ActivateForProtocol([In] String appUserModelId, [In] IntPtr itemArray, [Out] out UInt32 processId);
}
[ComImport, Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")]
private class ApplicationActivationManager : IApplicationActivationManager
{
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
public extern IntPtr ActivateApplication([In] String appUserModelId, [In] String arguments, [In] ActivateOptions options, [Out] out UInt32 processId);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
public extern IntPtr ActivateForFile([In] String appUserModelId, [In] IntPtr itemArray, [In] String verb, [Out] out UInt32 processId);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
public extern IntPtr ActivateForProtocol([In] String appUserModelId, [In] IntPtr itemArray, [Out] out UInt32 processId);
}
public static int LaunchMetroAppFormAppID(string aAppID, string pArg = null)
{
ApplicationActivationManager aManager = new ApplicationActivationManager();
uint aPid;
aManager.ActivateApplication(aAppID, pArg, ActivateOptions.None, out aPid);
return (int)aPid;
}
#endregion
以上是关于csharp C#中启动Metro应用的主要内容,如果未能解决你的问题,请参考以下文章
csharp Cronómetro
如果 Metro 应用程序被操作系统终止,启动 Metro 应用程序的正确方法是啥?
可以在“Metro”环境和桌面环境中启动应用程序吗? - 视窗 8/8.1
如何在 Metro (C++/CX) 应用程序中解析日期?
如何更改 Metro 应用程序的 XAML/C# 中单选按钮的样式?
如何在C#的metro应用程序中使用contactPickerUI添加联系人?