如何打开与FireMonkey跨平台应用程序的默认浏览器的网址是什么? [英] How to open an URL with the default browser with FireMonkey cross-platform applications?

查看:212
本文介绍了如何打开与FireMonkey跨平台应用程序的默认浏览器的网址是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常情况下,我使用:的ShellExecute(0,'开放',PChar类型(edtURL.Text),'','',SW_SHOWNORMAL);

Usually, I use: ShellExecute(0, 'OPEN', PChar(edtURL.Text), '', '', SW_SHOWNORMAL);

我怎么能有相同的行为(如打开在默认浏览器的链接),在所有平台(Windows OSX)?

How can I have the same behaviour (opening a link in the default browser), on all platforms (Windows and OSX)?

推荐答案

在FireMonkey论坛,我发现这个code为约NSWorkspace.URLForApplicationToOpenURL问题:

In the FireMonkey discussion forum I found this code for a question about NSWorkspace.URLForApplicationToOpenURL:

uses
  Posix.Stdlib;
....
  _system(PAnsiChar('open ' + ACommand));

(不是我测试)

更新:Posix的不可用在Windows所以这是不可能写出它使用在所有平台上使用相同的操作系统调用的解决方案。我建议,其中有一些POSIX IFDEF等中央XPlatform单位提出这样code

Update: Posix is not available on Windows so it is not possible to write a solution which uses the same OS calls on all platforms. I suggest to move such code in a central 'XPlatform' unit which has some IFDEF POSIX etc.

这篇关于如何打开与FireMonkey跨平台应用程序的默认浏览器的网址是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆