From f06832c1b6caae13c0bddf8f3a8aeb1114f4392b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 2 Aug 2008 15:31:38 +0000 Subject: [PATCH] implement wxLaunchDefaultApplication() for MSW and document it (#9810) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54926 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- interface/wx/utils.h | 12 ++++++++++++ src/common/utilscmn.cpp | 18 +++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/interface/wx/utils.h b/interface/wx/utils.h index 8bade8cd74..2e49aaf7bd 100644 --- a/interface/wx/utils.h +++ b/interface/wx/utils.h @@ -421,6 +421,18 @@ long wxNewId(); */ void wxRegisterId(long id); +/** + Opens the @a document in the application associated with the files of this + type. + + The @a flags parameter is currently not used + + Returns @true if the application was successfully launched. + + @header{wx/utils.h} +*/ +bool wxLaunchDefaultApplication(const wxString& document, int flags = 0) + /** Opens the @a url in user's default browser. diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index a0aa6a98c4..c77b3e3743 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -937,11 +937,11 @@ void wxQsort(void *const pbase, size_t total_elems, // Launch document with default app // ---------------------------------------------------------------------------- -bool wxLaunchDefaultApplication(const wxString &document, int flags) +bool wxLaunchDefaultApplication(const wxString& document, int flags) { wxUnusedVar(flags); -#ifdef __UNIX__ +#if defined(__UNIX__) // Our best best is to use xdg-open from freedesktop.org cross-desktop // compatibility suite xdg-utils // (see http://portland.freedesktop.org/wiki/) -- this is installed on @@ -954,9 +954,21 @@ bool wxLaunchDefaultApplication(const wxString &document, int flags) if ( wxExecute(xdg_open + " " + document) ) return true; } +#elif defined(__WXMSW__) + const INT_PTR result = (INT_PTR)::ShellExecute + ( + NULL, // parent window + _T("open"), + document, + NULL, // parameters + NULL, // working directory + SW_SHOWDEFAULT + ); + if ( result > 32 ) + return true; #endif - return false; + return false; } // ---------------------------------------------------------------------------- -- 2.45.2