Thread: Want to end a few processes

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    25

    Want to end a few processes

    Hey,
    been programming for years but never done a windows program. I have had a few problems with pairs of processes that keep opening each other when I close one of them. Basically, they are very difficult to delete (as windows throws some error message saying the file is in use).

    I want to see if I can write a quick program that can end both processes far quicker than I can do manually. Something like, I find out the name of the processes ("irritatingopener.exe" and "openopener.exe"), type them in, and have them both ended instantly. I'm aware that there are probably better ways of deleting these files, but I would like to do this as an exercise (it would be a thrill if it worked though).

    How would I get started? Would this sort of thing be easy to do?

  2. #2

  3. #3
    Registered User
    Join Date
    Oct 2004
    Posts
    25
    I think that article has most of the functions I need, however I still can't work out how to get a handle on an external process. Most of the microsoft API seems to assume you already have this handle.

  4. #4

  5. #5
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    You could find what you are looking for in this article: How To Enumerate Applications Using Win32 APIs

    Edit: or alternately just use the above solution.

  6. #6
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544

  7. #7
    Registered User
    Join Date
    Oct 2004
    Posts
    25
    I like the look of that 'terminating a process by name' thing, but I don't think it works in this instance since Winspy can only look at visible windows (whereas I'm looking to shut down hidden background processes). I don't know how I'd get the 'class name' of something without winspy.

    I've had a look at Madcow's link to msdn. It looks a lot like what I want, but I can't run the example code they have. It (DevC++) complains about 'void main'. When I change it to int main, the code simple does nothing.
    Edit: my mistake, got it working. Will start fiddling with it now

    Why do at least half the processes listed have 'access is denied'? Is there any way I can force them to shut down, or at least access them? Most of them are listed as 'System' by the task manager, and many of the more annoying background apps also declare themselves as system. I hope this doesn't prevent the whole program from working
    Last edited by Swordsalot; 02-20-2006 at 10:41 PM.

  8. #8
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    you can delete the programs altogether after booting into safemode (or command prompt, if available).
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Overwriting all in array, why?
    By guesst in forum C Programming
    Replies: 7
    Last Post: 10-09-2008, 05:56 PM
  2. ISO 8583 Message Parser in C?
    By nadeer78 in forum Projects and Job Recruitment
    Replies: 7
    Last Post: 06-16-2008, 12:56 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. socket newbie, losing a few chars from server to client
    By registering in forum Linux Programming
    Replies: 2
    Last Post: 06-07-2003, 11:48 AM
  5. Next Question...
    By Azmeos in forum C++ Programming
    Replies: 3
    Last Post: 06-06-2003, 02:40 PM