是否有非java,跨平台的方式来启动某个文件类型的关联应用程序? [英] Is there a non-java, cross platform way to launch the associated application for a certain file type?

查看:131
本文介绍了是否有非java,跨平台的方式来启动某个文件类型的关联应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我发现了一对夫妻 java特定问题和答案。我正在寻找更多的本地,但跨平台解决方案,使用C,C ++,某种shell脚本,或者,在我的情况下,Qt。

First, I found a couple of java specific questions and answers for this. I am looking for more "native", but cross platform solution, using C, C++, some kind of shell scripts, or, in my case, Qt.

所以问题是,是否有标准,跨平台,以编程方式打开某些文件类型的关联应用程序的方式。

So the question is, are there standard, cross platform, ways to programmatically open the associated application for certain file types. Or at least to find out if there are associated applications and be able to locate and launch them?

通过跨平台我的意思是Windows,OSX和linux(gnome / kde),或者至少找出是否有相关联的应用程序并且能够定位和启动它们。 。

By cross platform I mean Windows, OSX and linux (gnome/kde). The use case is having a database with stored files as blobs that will be read on the three different targets.

推荐答案

我不知道如何使用这些数据库,

I don't know of any cross-platform way.

在Windows中,有 start 命令将启动相关联的默认应用程序。 (例如 start foo.doc 将启动默认Word文档编辑器,启动 http ://StackOverflow.Com/ 默认网络浏览器和启动mailto:mail@example.com 默认邮件应用程序。

In Windows, there is the start command, which will launch the associated default application. (E.g. start foo.doc will launch the default Word document editor, start http://StackOverflow.Com/ the default web browser and start mailto:mail@example.com the default mail app.)

在OS X中有 open 命令,这样做也是一样。

In OS X there is the open command, which does the same thing.

Linux只是一个操作系统内核。 OS内核不知道任何关于文件类型或MIME类型或关联应用程序或任何类似的东西。因此,对于Linux来说,这样的事情只是不能存在

Linux is just an Operating System kernel. OS kernels don't know anything about "filetypes" or "MIME types" or "associated applications" or anything like that. Therefore, such a thing simply cannot exist for Linux.

Freedesktop组有 xdg-open 命令的.Org / xdg-utils-1.0 / xdg-open.html规范,适用于所有符合Freedesktop的图形桌面(无论是Linux,FreeBSD,NetBSD,OpenBSD,DragonflyBSD,OpenSolaris还是其他)。然而,显然不能保证在非Freedesktop系统上工作,并且肯定不能保证在非图形系统上工作。

The Freedesktop Group has a specification for an xdg-open command, which works on all Freedesktop-compliant graphical desktops (be they Linux, FreeBSD, NetBSD, OpenBSD, DragonflyBSD, OpenSolaris or otherwise). However, it is obviously not guaranteed to work on non-Freedesktop systems and it is certainly not guaranteed to work on non-graphical systems.

在所有这三种情况下,这是一个命令行应用程序,而不是C或C ++ API,但你可以明显地通过 system 来调用它。

In all three cases, this is a command line application, not a C or C++ API, but you can obviously call it via system.

这篇关于是否有非java,跨平台的方式来启动某个文件类型的关联应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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