0

メトロアプリを起動するときにメトロアプリからwin32デスクトップに入りたい(メトロ起動画面でアプリのタイルを押す)。1つの方法は、メトロアプリの起動時にファイル(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
         {
         }
    }
}

}

4

1 に答える 1

0

BatRTを使用すると、metro アプリからバッチ ファイルを実行できます。これは、metro アプリから任意のデスクトップ アプリケーションを実行するために使用できます。Metro アプリが起動したらすぐにバッチ ファイルを実行して、目的のデスクトップ アプリケーションを実行します。

于 2013-05-18T20:26:12.253 に答える