none
metro可以调用桌面浏览器么? RRS feed

答案

  • 您好!

    你需要设置LauncherOptions.DisplayApplicationPicker属性为TRUE,让用户选择具体的应用打开相应资源。

    用户可以选择Metro应用,也可以选择桌面应用。这取决于用户的最终控制。

    但是你不能直接在代码中调用桌面浏览器(比如:传统桌面应用中通过CreateProcess执行其他程序, CreateProcess API不能在Metro应用中使用)。

    样例代码如下

    // Path to the file in the app package to launch
       string imageFile = @"abc.jpeg";
    
       var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);
    
       if (file != null)
       {
          // Set the option to show the picker
          var options = new Windows.System.LauncherOptions();
          options.DisplayApplicationPicker = true;
    
          // Launch the retrieved file
          bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
       }
       

    请参考 Launcher.LaunchFileAsync(IStorageFile)


    Best wishes,


    Robin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2012年4月23日 6:40
    版主

全部回复

  • 您好!

    你需要设置LauncherOptions.DisplayApplicationPicker属性为TRUE,让用户选择具体的应用打开相应资源。

    用户可以选择Metro应用,也可以选择桌面应用。这取决于用户的最终控制。

    但是你不能直接在代码中调用桌面浏览器(比如:传统桌面应用中通过CreateProcess执行其他程序, CreateProcess API不能在Metro应用中使用)。

    样例代码如下

    // Path to the file in the app package to launch
       string imageFile = @"abc.jpeg";
    
       var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);
    
       if (file != null)
       {
          // Set the option to show the picker
          var options = new Windows.System.LauncherOptions();
          options.DisplayApplicationPicker = true;
    
          // Launch the retrieved file
          bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
       }
       

    请参考 Launcher.LaunchFileAsync(IStorageFile)


    Best wishes,


    Robin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2012年4月23日 6:40
    版主
  • 还有一种就是用户设置非ie为默认浏览器...然后你调用的都是桌面浏览器了。。。
    2012年4月23日 11:47