PDA

View Full Version : use qprocess like shellexecute



kernel_panic
19th February 2007, 13:09
Hi all!

Is it possible to use QProcess like the WinAPI Shellexecute?
I would like to print several Documents and i do this with

ShellExecute(NULL, (LPWSRT)"print", (LPWSTR)doc.utf16(), NULL,NULL,SW_HIDE);
But i have to wait until the process is finished, but i can't do this with ShellExecute and
ShellExecuteEx doesn't work really?

Now can i do the same like ShellExecute with qprocess?
THX

wysota
19th February 2007, 13:24
Yes, of course. Just call cmd.exe as the program to start and communicate with its stdin/stdout if you need the shell (it's possible that you don't). If you don't need the shell, call the application you want directly from QProcess.

kernel_panic
19th February 2007, 13:39
i want to print the document directly.
i can do this with

ShellExecute(NULL, (LPWSRT)"print", (LPWSTR)doc.utf16(), NULL,NULL,SW_HIDE);

can i do this with the cmd and qprocess, isn't it possible to do this without cmd?

wysota
19th February 2007, 13:50
If "print" is an application then you can do it without cmd. But if "print" is a command implemented by cmd, then you need cmd to run it. Just try it and see what you get.

kernel_panic
19th February 2007, 13:58
"print" is a verb, no parameter or program. it says ShellExecute, that it shall say the program(which is bound with the ending, ShellExecute gets a filename and opens the program bound to it bsp test.txt, ShellExecute opens Notepad.exe, which shows the test.txt) "print the document that i give you and close".

wysota
19th February 2007, 14:05
So it needs cmd.exe.

kernel_panic
19th February 2007, 15:50
please give me an example how i can print my test.txt with the cmd

wysota
19th February 2007, 16:51
You might have searched the forum...
Check http://www.qtcentre.org/forum/showthread.php?t=3712