Thread: Closing a program -help

  1. #1
    Unregistered
    Guest

    Closing a program -help

    Is there a way to close another program with C

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Yeah. You can close a program if you know what section of memory it resides in. Make a pointer to it, and over write its contents with random garbage. Your other program will crash (so will your main program) and you'll be all done. Mission accomplished.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Is there a way to close another program with C
    Build a robot arm, write a program in C to control that arm so that it hits the power button on your computer. Poof, you closed another program with C.

    -Prelude
    My best code is written with the delete key.

  4. #4
    Unregistered
    Guest

    thanks but can you

    can you give me an example

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    My best code is written with the delete key.

  6. #6
    Unregistered
    Guest

    okay so I did it and it gave me an error

    i tried this:
    fopen("c:/windows/desktop/CIPchat.exe", "w");
    fprintf("kdlfj");

    the program said...
    Sharing violation reading drive C
    retry/fail/

    i retryed but the same happened

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826

    Re: okay so I did it and it gave me an error

    Originally posted by Unregistered
    i tried this:
    fopen("c:/windows/desktop/CIPchat.exe", "w");
    fprintf("kdlfj");

    the program said...
    Sharing violation reading drive C
    retry/fail/

    i retryed but the same happened
    This thread cracks me up. You realize... well maybe not.

    No, you don't write over top of the executable. I was talking about the memory (not disk space) that the program is currently using. Nevermind. Too funny.

    Quzah.
    Hope is the first step on the road to disappointment.

  8. #8
    Unregistered
    Guest

    wait...

    i tried it again on a different file, but this time it didn't crash the program, but when i closed it manualy and ran it again it would not run. I don't want to mess the exe up, i only want to crash/close it, an be able to run it again without a problem

  9. #9
    Unregistered
    Guest

    okay qzah then...

    okay then how do i do that, i messed up 3 exe by testing out my last example.

  10. #10
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826

    Re: wait...

    Originally posted by Unregistered
    i tried it again on a different file, but this time it didn't crash the program, but when i closed it manualy and ran it again it would not run. I don't want to mess the exe up, i only want to crash/close it, an be able to run it again without a problem
    Hahah. Oh god. Tears of laughter... Thanks for the laugh.

    Quzah.
    Hope is the first step on the road to disappointment.

  11. #11
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >okay then how do i do that, i messed up 3 exe by testing out my last example.
    Between fits of laughter I really do wonder.

    -Prelude
    My best code is written with the delete key.

  12. #12
    Unregistered
    Guest

    Someone please help

    please help all i need is one small example, laugh if you want but this is important

    -prelude, what the hell

  13. #13
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    IF you know the window handle of the app window you want to close, you can use win32api.

    Heres a link from a visual basic board. It mentioned the use of SendMessage API:

    http://www.ibiblio.org/pub/languages.../append-c.html

    I don't think there's an ANSI way of doin it, since your issue is platform-specific.
    Last edited by Nutshell; 04-19-2002 at 07:07 PM.

  14. #14
    Evil Member
    Join Date
    Jan 2002
    Posts
    638
    If you are using windows, then use a message, look into msdn for the specifics.

    If not, you will have to look into how your machine handles interprocess communications. Pipes, semaphores, and other entirely too confusing methods.

    Trying to crash a program by scramming it's memory is a bad way of doing that, and it was suggested as a joke (that or quzah's cheese slid off his cracker)

  15. #15
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >that or quzah's cheese slid off his cracker
    That happened a long time ago.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  2. exiting and closing a program
    By major_small in forum C++ Programming
    Replies: 10
    Last Post: 05-30-2003, 08:31 PM
  3. How to restart a program without closing it...
    By D4050 in forum C++ Programming
    Replies: 16
    Last Post: 10-31-2001, 12:38 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM