From: Iulian-Nicu Șerbănoiu on
To solve all these problems you could use ShellExecute (only) under
Windows if that suits your purpose.
It is clearly that in the *nix world it is not so easy thing to make a
similar function that will work the same regardless of the desktop
environment you're using (gnome, kde, xfce ...).

Regards,

Iulian

On Thu, Dec 11, 2008 at 6:29 PM, ecrucru <ecrucru(a)gmail.com> wrote:
> Hello I would like to report something strange to me with wxMSW and
> wxExecute... I don't use wxProcess.
>
> The fact is: wxExecute has not the same behaviour as
> "Windows>Start>Execute". By trying to run "firefox http://foobar", WX
> fails, Windows succeeds.
>
> 1) Does WX use ShellExecute (API) ? For me, no, because "firefox url"
> must be exploded to fill in ShellExecuteInfo.
>
> 2) WX checks global envvar "PATH" to find the app. But I notice that
> WX searches for "firefox" and also for "firefox url" (in this case,
> the slashes have a strange appearance)
>
> 3) To find 'firefox' even if the path is not set in 'PATH', the
> technique is to check the registry in
> "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths". WX
> doesn't do it.
>
> I have a sample to submit (see below) but no patch.
>
> RefDocs:
> --> http://docs.wxwidgets.org/stable/wx_processfunctions.html#wxexecute
> --> http://wiki.wxwidgets.org/WxExecute
> --> http://docs.wxwidgets.org/stable/wx_wxprocess.html#wxprocessopen
>
>
> ecrucru
>
> ---------------------------------------------
>
> #include "wx/wxprec.h"
> #ifdef __BORLANDC__
> #pragma hdrstop
> #endif
> #ifndef WX_PRECOMP
> #include "wx/wx.h"
> #endif
>
> class wxExecApp: public wxApp
> {
> public:
> virtual bool OnInit();
> };
>
> DECLARE_APP(wxExecApp)
> IMPLEMENT_APP(wxExecApp)
>
> bool wxExecApp::OnInit()
> {
> wxMessageDialog(NULL, wxT("The software will launch apps. Each time,
> you must close them to continue.")).ShowModal();
> wxExecute(wxT("calc"), wxEXEC_SYNC);
> wxMessageDialog(NULL, wxT("OK")).ShowModal();
> wxExecute(wxT("\"C:\\Program Files\\Mozilla\\Firefox\\firefox.exe\"
> http://www.wxwidgets.org"), wxEXEC_SYNC);
> wxMessageDialog(NULL, wxT("OK")).ShowModal();
> wxExecute(wxT("firefox http://www.wxwidgets.org"), wxEXEC_SYNC);
> wxMessageDialog(NULL, wxT("FAILURE")).ShowModal();
> return false;
> }
> _______________________________________________
> wx-users mailing list
> wx-users(a)lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wx-users
>
From: ecrucru on
VZ> Instead the main requirement is that it should work the same under all
VZ> platforms. If you need ShellExecute() you should have a look at
VZ> wxLaunchDefaultBrowser() and/or wxLaunchDefaultApplication()

My idea was to use Firefox instead of the default browser. The reason
is to create a menu : open with opera, open with ff, open with
foobar...


VZ> All wx does is to pass the command line to Win32 CreateProcess()
VZ> function.

I thought the command was parsed to separate command and parameters.
When using CreateProcess(), the app searches for "firefox.exe" (not
found) and "firefox.exe http:\www.wxwidgets.org" (invalid name) in
various folder : ., windows, system, system32...

It is the reason why I was wondering about ShellExecute which has no problem.


IS> To solve all these problems you could use ShellExecute (only) under
IS> Windows if that suits your purpose.
IS> It is clearly that in the *nix world it is not so easy thing to make a
IS> similar function that will work the same regardless of the desktop
IS> environment you're using (gnome, kde, xfce ...).

You're right and it works fine (Windows only).

Thanks a lot for your replies.
Best regards

ecrucru