--enable-runtime-pseudo-reloc support in cygwin, take 3.

Charles Wilson cwilson@ece.gatech.edu
Mon Dec 2 13:56:00 GMT 2002


ed> Question: How can one distinguish console application from GUI one?
ed> What is the best wording for the error message?

Here's an example.  If GetConsoleWindow is available (W2K or XP) it uses 
that; otherwise, it uses a different kludge.

The idea is you'd call has_console() or 
GetConsoleWindow()/GetConsoleWindow2() only once, and your app would 
cache the result.  However, since Egor's use would be to display/print 
an error message and die, I don't suppose that matters much...

works as expected in all these cases:

gcc -o has_console.exe has_console.c
gcc -mwindows -o has_console.exe has_console.c
gcc -mno-cygwin -o has_console.exe has_console.c
gcc -mno-cygwin -mwindows -o has_console.exe has_console.c

Note that all that matters is how the app was *compiled*.  If you happen 
to run an app that was compiled with -mwindows by typing its name in a 
bash shell, it still "thinks" its a GUI app, and uses MessageBox to 
display the "error" message.

If you want it to detect how it was called (e.g. exec'ed by an 
interactive bash shell, or clicked in Windows Explorer) then you've got 
to use a different solution.

--Chuck
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: has_console.c
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20021202/4760ae38/attachment.c>


More information about the Cygwin-patches mailing list