Thread: An "throwing exception" issue

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    3

    Post An "throwing exception" issue

    Hi!
    I was planning to build a small app in C++ or even C to run another 2 Win32 apps, in the following manner: The app tries to run the first .exe, and if it is not successful, runs the second .exe.
    I tried something like this:
    Code:
     
    try { 
    system("start something.exe"); 
    } catch (<exception, don't know what>) {
    system("start another.exe");
    }
    Well, it didn't work... can anyone help me on this one? Thanks a lot!

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    The system function does not throw as far as I know, so try and catch blocks won't work. If you wan't to check to see if a file exists, you should look into file input/output.

    Edit:

    Info on system() function

    C++ exceptions (found randomly on google)
    Last edited by JaWiB; 06-01-2004 at 05:52 PM.
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    ...Or use ShellExecute() or CreateProcess() which return a value which indicates if the program was started successfully.

  4. #4
    Registered User
    Join Date
    Jun 2004
    Posts
    3
    Thank you guys! I didn't know system() can't throw (newbie!)... Thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. float calculation issue
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-26-2008, 04:56 AM
  2. type safe issue
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 02-12-2008, 09:32 PM
  3. Metaprogramming Issue
    By schultz in forum C++ Programming
    Replies: 8
    Last Post: 10-08-2007, 05:11 PM
  4. Idle Issue.
    By Charmy in forum C++ Programming
    Replies: 7
    Last Post: 06-24-2005, 06:10 AM
  5. my first issue of GDM
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 09-12-2002, 04:02 PM