HBQT - run windows associate files and paths with spaces (qProcess)

154 views
Skip to first unread message

Zoran Sibinovic

unread,
Nov 13, 2011, 4:33:01 AM11/13/11
to Harbour Developers
HI,

I tried to launch a .pdf file as file associate in windows with adobe
reader (acrord32.exe), but i haven't found adequate function/code/
class to do it, so...

I tried to start adobe acrobat with qProcess, little odd a cause of a
different inst folders depend of adobere different releases and found
that oQproc:startDetached ("c:\Program Files\Adobe\Reader 10.0\Reader
\acrord32.exe")
wan't work, of course for the spaces in the path. AlreadyI tried lot
of "\" c:\\Program files\\.. and other combinations found on the net.

Looking around i haven't found in any article explicitly how to start
a file ex. .pdf with his associate program and no working explanation
of writing a path with spaces to make it understandable by windows

In advance,
thanks for helping

Zoran

Zoran Sibinovic

unread,
Nov 13, 2011, 7:17:41 AM11/13/11
to Harbour Developers
Hi,

in the meanwhile I found 1 way to start an app with spaces in the path

oQproc:startDetached ( 'c:\"Program Files"\Adobe\"Reader 10.0"\Reader
\AcroRd32.exe file.pdf' )

Zoran

2D Info - Leandro Damasio

unread,
Nov 13, 2011, 2:25:26 PM11/13/11
to harbou...@googlegroups.com
Hi Zoran,
Under windows one can use ShellExecute function to open a document with its associated program.
ShellExecute function documentation is in this link and Harbour implements WAPI_ShellExecute function as a PRG level wrapper in harbour\contrib\hbwin.
To open a PDF documento with the associated program using ShellExecute one just have to indicate the document file name and set the operation type to "open".
Wouldn't it be the same case using QT? I mean, isn't it enough to indicate the document name and let the OS do call the appropriate program to open it?
Regards,
Leandro

Zoran Sibinovic

unread,
Nov 14, 2011, 2:11:49 AM11/14/11
to Harbour Developers
Hi Leandro,

I agree with you,

there are 2 ways, one using the the Wapi_Shellexecute() function,
including the hbwin, and, the other, calling directly the application
specifying the path. The functions works both and the problems are
solved. It just that I want to explore if can be found some QT method
to do it, like using Qprocess, to invoke the opening of the associated
file, if that kind of method exist.

1. oItem11 : connect ( " triggered ( bool )", { ||
Wapi_ShellExecute( NIL, "open", "file.pdf" ) } )

2. oItem11 : connect ( " triggered ( bool )", { ||
oQproc:startDetached ( 'c:\"Program Files"\Adobe\"Reader 10.0"\Reader
\AcroRd32.exe file.pdf' ) } )

Thanks for answer

Zoran
Reply all
Reply to author
Forward
0 new messages