hello all
i have simple Win32 gui application ( simple window )
but when i close the window the application still remains in the task manger processes list
how can i terminate the process completely with win32 api?
hello all
i have simple Win32 gui application ( simple window )
but when i close the window the application still remains in the task manger processes list
how can i terminate the process completely with win32 api?
Either the window is simply closing without ever exiting the message loop, or there's another thread still running in the app.
Post your code for further assistance.
gg
well in my code i have :
but i have another thread runing in the background alsoPHP Code:
case WM_CLOSE :
DestroyWindow(hwnd);
break;
case WM_DESTROY :
PostQuitMessage(0);
break;
What about notifying the background thread that it needs to exit as well?
In your multi-threading programs you should always keep track of their thread ids (this is the microsoft prescribed way of doing things) so you can end them nicely. The alternative (which I have found works better in some instances) is have a KeepAlive() function that is polled by sub-threads (assuming they are looping, of course) and exit accordingly.
Do you pass hwnd in your GetMessage call? If so, pass NULL instead.
It's a filter parameter. If you pass a HWND to it, it only gives you messages for that window. If you pass NULL, it gives you all messages. WM_QUIT is not a window-specific message; you only get it if you pass NULL. As such, if your main application loop passes the hwnd from CreateWindow, after the window is destroyed the program will hang forever in that GetMessage call, waiting for messages for a window that no longer exists.
HANDLE Process;
Process = OpenProcess(PROCESS_ALL_ACCESS , true , GetCurrentProcessId());
TerminateProcess(Process , 0);