how to terminate process from Task Manager -> Processes -> MyApplication.exe

This is a discussion on how to terminate process from Task Manager -> Processes -> MyApplication.exe within the C++ Programming forums, part of the General Programming Boards category; hello all i have simple Win32 gui application ( simple window ) but when i close the window the application ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    58

    how to terminate process from Task Manager -> Processes -> MyApplication.exe

    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?

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,659
    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

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    58
    well in my code i have :
    PHP Code:
    case WM_CLOSE :
          
    DestroyWindow(hwnd);
          break;

       case 
    WM_DESTROY :
          
    PostQuitMessage(0);
          break; 
    but i have another thread runing in the background also

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    What about notifying the background thread that it needs to exit as well?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  5. #5
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    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.

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Do you pass hwnd in your GetMessage call? If so, pass NULL instead.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Banned
    Join Date
    Nov 2007
    Posts
    678
    Quote Originally Posted by CornedBee View Post
    Do you pass hwnd in your GetMessage call? If so, pass NULL instead.
    I am also curious about it, I always passed null here, even though i have my HWND ready at the time, and it worked, why so?

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    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.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  9. #9
    Registered User
    Join Date
    Nov 2002
    Posts
    315
    HANDLE Process;
    Process = OpenProcess(PROCESS_ALL_ACCESS , true , GetCurrentProcessId());
    TerminateProcess(Process , 0);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Task Manager: Applications vs Processes
    By Shwick in forum Windows Programming
    Replies: 3
    Last Post: 08-14-2008, 06:47 AM
  2. start and stop a process in task manager
    By valthyx in forum C++ Programming
    Replies: 6
    Last Post: 07-21-2008, 01:12 PM
  3. process programming
    By St0rM-MaN in forum Linux Programming
    Replies: 2
    Last Post: 09-15-2007, 07:53 AM
  4. binary tree of processes
    By gregulator in forum C Programming
    Replies: 1
    Last Post: 02-27-2005, 11:59 PM
  5. Replies: 5
    Last Post: 04-17-2003, 07:07 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21