[英]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.