积极答复者
metro可以调用桌面浏览器么?

问题
答案
-
您好!
你需要设置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.
- 已标记为答案 Jie BaoModerator 2012年5月2日 7:25
全部回复
-
您好!
你需要设置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.
- 已标记为答案 Jie BaoModerator 2012年5月2日 7:25
-
还有一种就是用户设置非ie为默认浏览器...然后你调用的都是桌面浏览器了。。。
- 已建议为答案 Jie BaoModerator 2012年5月2日 7:25