No problem Tim. I am not a Windows developer so I barely know what I am talking about.
I am in fact NOT in a windowed environment. I have a background process that is spawned by a GUI that I want to kill gracefully. I am trying to emulate the pattern that I use on Linux: os.kill(pid, signal.SIGTERM) ... signal.signal(signal.SIGTERM, shutdown) ... My understanding is that I need a window to receive messages (such as WM_CLOSE) so that I can shutdown gracefully when killed by the task manager or my GUI. I am using PostMessage to send a WM_CLOSE to the daemon currently. I don't think I am going to end up using a WndProc as that brings a lot of overhead, namely the need to call PumpWaitingMessages() or similar. The solution I am looking at right now is to simply create a hidden window and then call PeekMessage() passing it's hwnd. This polling method is simpler and works better with the structure of the daemon. I can simply check for messages inside each iteration of my main loop and exit when WM_CLOSE is received. However, this discussion does raise a couple questions. 1. Do I in fact need a window to receive a WM_CLOSE message? If not, how do I post a message to a process, rather than a window? 2. Why is there two flavors of SetWindowLong() (win32gui and win32api)? 3. If I DO need a window to receive messages, what is the best way to find said window? Currently I am using FindWindow, but I am not very happy searching for the window by it's title, I would be happier with an approach that allowed me to enumerate the windows that belong to a given process (I have the pid readily available). I tried EnumWindows() and then checking the pid using GetWindowThreadProcessId() inside the callback but my window was not returned using this method. My guess is that this is because it is not a "top-level" window, or that it is not visible? Anyway, thank you for taking the time to respond, the information you provided is valuable, I think probably my problem was that originally I was not creating a window, and thus had no hwnd to pass to SetWindowLong() only my process handle. _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32