【问题标题】:enter win32 desktop from metro app at its startup在启动时从 Metro 应用程序进入 win32 桌面
【发布时间】:2012-08-31 08:27:41
【问题描述】:

我想在启动 Metro 应用程序时从 Metro 应用程序进入 win32 桌面(在 Metro 启动屏幕上按应用程序的磁贴)。一种方法是在启动 Metro 应用程序时打开文件(例如 TXT 文件)。我在 OnLaunched 中添加了以下代码逻辑,有时可以打开文件并进入桌面,但有时不能。有人可以帮助我吗? (只需在 VS2012 中创建一个空白应用程序)。

async protected override void OnLaunched(LaunchActivatedEventArgs args) {
// Do not repeat app initialization when already running, just ensure that the window     //is active
if (args.PreviousExecutionState == ApplicationExecutionState.Running)
{
    Window.Current.Activate();
    return;
}
if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
    //TODO: Load state from previously suspended application
}

// Create a Frame to act navigation context and navigate to the first page
// var rootFrame = new Frame();
if (!rootFrame.Navigate(typeof(MainPage)))
{
    throw new Exception("Failed to create initial page");
}

// Place the frame in the current Window and ensure that it is active
Window.Current.Content = rootFrame;
Window.Current.Activate();
{
    string txtfile = @"Assets\a.txt";
    var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(txtfile);

    if (file != null)
    {
         bool success = await Windows.System.Launcher.LaunchFileAsync(file);
         if (success)
         {
         }
         else
         {
         }
    }
}

}

【问题讨论】:

  • 您是否尝试过创建一个启动时立即退出的 WinForms 应用程序并启动它?

标签: c# microsoft-metro desktop launcher


【解决方案1】:

BatRT 允许您从 Metro 应用程序执行批处理文件。这可用于从 Metro 应用程序运行任何桌面应用程序。 Metro 应用程序启动后,立即执行批处理文件以运行所需的桌面应用程序。

【讨论】:

    猜你喜欢
    • 2012-03-20
    • 1970-01-01
    • 2010-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多