[python-win32] Control-C
David Schnepper
davidsch at verity.com
Fri Oct 14 17:38:49 CEST 2005
Mark Hammond wrote:
>Sadly, I think GenerateConsoleCtrlEvent will not work for you. In
short, it
>is nearly useless :) The description of the function says it "sends a
>specified signal to a console process group that shares the console
>associated with the calling process" and it means it literally. In
your
>case, it sounds like you have a GUI program, so that will not have a
>console, so will never be able to be part of your process group. If
the
>running program is not in the exact same console as your app, you are
hosed.
>
>More info on this can be found at
>http://www.microsoft.com/msj/0698/win320698.aspx, where they describe a
>technique where they need to use another child process to make this
work -
>but even then its not clear it would work if you app is a GUI one.
>
>
Thank you for the link. I'll check it out. I hadn't had the chance to
try the GenerateConsoleCtrlEvent yet.
----------------
The Windows notion of a "Console" is independent from a "visual window
on
the display". You can still have a Console without anything appearing
on the screen. Generally, if you start a process from a cmd.exe
window you inherit the cmd.exe window as your console, if your process
is started from the Services Manager you have no console -- but can
allocate one with AllocConsole().
A process can disassociate itself from a console with FreeConsole() -
and a good way to find out if you have a console is call
AllocConsole() and check for an error -- if you already had a console
an error code is returned.
A process can spawn a child detached from the console, or with a new
console, with flags to CreateProcess()
David Schnepper
Ultraseek Software Craftsman
david.schnepper at verity.com +1-408-542-2306
More information about the Python-win32
mailing list