Re: Console window opening during system() call inside GTK User Interface





I completely understand the argument, and I am looking forward for the
wrapper.

Moreover, making the exe[input into textbox]is not in the control of the
developer[that is our team], and so nothing can be done right at the time
of creation of the executable. What can only be done is modification of
the executable with the one-bit change in its header[hopefully my software
will have permission to do that with the executable]. Please keep this in
mind too.

Vijay

On Tue, January 15, 2008 3:24 pm, jcupitt gmail com wrote:
2008/1/15  <vijayasarathy setsindia net>:

I have a GTK base GUI, which takes an exe as input[from a text box
entry] and passes it to a function in a library, where there is a
system() call. So, there is no direct system() call in the GTK call back
or main function itself, GTK simply passes values to the library
function, which calls system(). And here is where the console window
pops up.

I spent some time looking into this recently when faced with a similar
problem.

On *nix systems, there's no difference between a GUI program and a
command-line program (a GUI program is just a command-line program that
opens a window).

However, windows (for historical reasons) has both
IMAGE_SUBSYSTEM_WINDOWS_GUI and IMAGE_SUBSYSTEM_WINDOWS_CUI
executables (possible values for the "executable type" field in the .exe).


The value of this field sets how windows starts the program: CUI
programs started from explorer get a command window showing input and
output which stays around for as long as the program is running, CUI
programs started from cmd.exe use that window for input and output and
block cmd.exe until they finish. CUI programs started from system() get a
console window and block. GUI programs get no command windows when started
from explorer, when started from cmd.exe or from system() they don't
block, and they get no IO either (I hope I have all that right).

Your problem is that you are trying to run a CUI program without a
console window via system() and it's just not possible. You need to write a
"wrapper" program, tagged as GUI, which starts the CUI program
for you without a console window. Apparently this is quite a commmon thing
for windows programmers to do: a friend sent me sample one, I can fwd itto
you when I'm back at work tomorrow.

There will be a further problem though: your system() call will no
longer block and you'll need to find some other way to wait for the child
program to finish.

As Allin said, don't use system() on windows if you can possibly avoid
it.

John

*************************************************************************************
DISCLAIMER 
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may 
contain confidential and privileged information. 
Any use,distribution,copying or disclosure by any other person is strictly prohibited. If you have received 
this transmission in error please notify SETS immediately either by replying to this e-mail or by telephone 
+91-44-28205655 and then delete this e-mail. The sender does not accept any responsibility for any damage 
which you sustain as a result of software viruses or malicious programs. You should therefore scan 
attachments (if any) prior to opening them. 
************************************************************************************







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]