简体   繁体   English

在启动时从Metro应用程序进入Win32桌面

[英]enter win32 desktop from metro app at its startup

I want to enter win32 desktop from a metro app when launch the metro app (press the app's tile on metro startup screen). 启动Metro应用程序时,我想从Metro应用程序进入win32桌面(在Metro启动屏幕上按应用程序的磁贴)。 One way is to open a file (eg a TXT file) when start the metro app. 一种方法是在启动Metro应用程序时打开文件(例如TXT文件)。 I add the following code logic into OnLaunched, sometimes it can open the file and enter desktop, but sometimes, it doesn't. 我将以下代码逻辑添加到OnLaunched中,有时它可以打开文件并进入桌面,但有时却不能。 Could someone help me? 有人可以帮我吗? (just create a blank app in VS2012). (只需在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
         {
         }
    }
}

} }

BatRT allows you to execute a batch file from a metro app. BatRT允许您从Metro应用程序执行批处理文件。 This could be used to run any desktop application from a metro app. 这可用于运行Metro应用程序中的任何桌面应用程序。 As soon as the metro app starts execute a batch file to run your desired desktop application. Metro应用程序启动后,立即执行批处理文件以运行所需的桌面应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Metro应用程序使用套接字流在C#中写入Win32 TCPListener - Metro app using socketstream to write to Win32 TCPListener in C# 是否可以从 windows 任务计划程序使用/不使用命令行参数启动/触发桌面桥接应用程序 (Win32)? - Is it Possible to launch/Trigger an desktop bridged app(Win32) with/without command line parameter from windows task scheduler? 如何使用UWP项目中的4个参数启动Win32可执行桌面 - How to launch win32 executable desktop with 4 arguments from UWP project LaunchFullTrustProcessForCurrentAppAsync 杀死 win32 应用程序 - LaunchFullTrustProcessForCurrentAppAsync kills win32 app 使用Win32 API获取桌面工作区矩形 - Using Win32 API to get desktop work area rectangle 如何检查MSI类型是否为c#中的Win32(非.net)、. Net,App混合(.Net和Win32)64位? - How to check MSI type if its Win32 (Non .net), .Net, App Mixed(.Net and Win32) 64 bit in c#? 如何从其 Win32 句柄中获取 System.Windows.Form 实例? - How do I get a System.Windows.Form instance from its Win32 handle? 我的Win32 App如何从UWP App窃取焦点? - How Can My Win32 App Steal Focus From My UWP App? 将文件从我的应用程序拖放到另一个应用程序的Win32 API过程 - The Win32 API procedure of drag-and-dropping a file from my app to another app Win32异常 - Win32 Exception
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM