MMazzon
MMazzon

Reputation: 394

How to launch Finder or other Mac apps from a wine (WineBottler) windows program

I'm writing a Windows program and I run it on the Mac using wine (WineBottler)

I'd like to be able to launch Finder or other MacOS applications from within my program.

I know that's possible because for example I can launch Safari with this line:

ShellExecute(0, 'open', 'http://www.google.com', nil, nil, 0);

I suppose that's because Safari is the default application for handling URLs. In fact, even this will still succeed in launching Safari:

ShellExecute(0, nil, 'www', nil, nil, 0);

On the other hand, passing other strings (e.g. path to a text file) will launch the wine-based default applications for those file types, if any.

So it looks that the above can launch either guest-os-based (e.g. Safari) applications, or wine-based applications, as the case may be.

So now, how can I, for example, launch Finder at a given folder? Or how do I open a give file, let's say an mp3 file, with the default Mac application, rather than a (non-existent) wine-based application for that file type?

Note: Possibly the way wine launches Safari is through the "iexplorer.exe" app included in wine -- possibly the registered app for URLs within wine -- but even then the question remains the same: How does that "iexplorer.exe" program call Safari, or whatever is the default app for URLs? And how can I do the same to launch the default app for browsing folders in MacOS? Or opening mp3 files, and so on?

I spent the last two hours trying everything I could think of, without success. I could also not find a solution on wine and wine-faq web sites.

I use Delphi but any Windows API-based answer is fine.

Can anybody help?

Thanks!

Upvotes: 0

Views: 591

Answers (1)

MMazzon
MMazzon

Reputation: 394

The answer is "winebrowser".

To open, for example, a folder with the native app (Finder) I can call:

ShellExecute(0, 'open', 'winebrowser', PChar(PathOfTheFolder), nil, 0);

In a similar way I can pass the path of a text file, to be opened by TextEdit (default app for *.txt files) and so on.

Upvotes: 1

Related Questions