Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Try...Catch Problem

Try...Catch Problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpsysadmindebuggingquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rover_boy
    wrote on last edited by
    #1

    Can anyone help me on a try catch block? Not quite sure on the catch block. I want it to display a message box if the error the path in the try block does not exist. try { System::Diagnostics::Process::Start("C:\\client\\debug\\client.exe"); } catch(char *ex) { MessageBox::Show ("Not able to connect to PANGU server!", "PANGU Server Error!"); } finally { }

    M H 2 Replies Last reply
    0
    • R rover_boy

      Can anyone help me on a try catch block? Not quite sure on the catch block. I want it to display a message box if the error the path in the try block does not exist. try { System::Diagnostics::Process::Start("C:\\client\\debug\\client.exe"); } catch(char *ex) { MessageBox::Show ("Not able to connect to PANGU server!", "PANGU Server Error!"); } finally { }

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Take a look at what exceptions the System::Diagnostics::Process::Start() method can throw. Ripped right from the docs...

      try
      {
      System::Diagnostics::Process::Start("C:\\client\\debug\\client.exe");
      }
      catch ( System::ComponentModel::Win32Exception^ w )
      {
      Console::WriteLine( w->Message );
      Console::WriteLine( w->ErrorCode );
      Console::WriteLine( w->NativeErrorCode );
      Console::WriteLine( w->StackTrace );
      Console::WriteLine( w->Source );
      Exception^ e = w->GetBaseException();
      Console::WriteLine( e->Message );
      }

      On my test, w->Message == "The system cannot find the file specified". Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      R 1 Reply Last reply
      0
      • R rover_boy

        Can anyone help me on a try catch block? Not quite sure on the catch block. I want it to display a message box if the error the path in the try block does not exist. try { System::Diagnostics::Process::Start("C:\\client\\debug\\client.exe"); } catch(char *ex) { MessageBox::Show ("Not able to connect to PANGU server!", "PANGU Server Error!"); } finally { }

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        You must ask your question on the correct forum Managed C++/CLI[^].

        1 Reply Last reply
        0
        • M Mark Salsbery

          Take a look at what exceptions the System::Diagnostics::Process::Start() method can throw. Ripped right from the docs...

          try
          {
          System::Diagnostics::Process::Start("C:\\client\\debug\\client.exe");
          }
          catch ( System::ComponentModel::Win32Exception^ w )
          {
          Console::WriteLine( w->Message );
          Console::WriteLine( w->ErrorCode );
          Console::WriteLine( w->NativeErrorCode );
          Console::WriteLine( w->StackTrace );
          Console::WriteLine( w->Source );
          Exception^ e = w->GetBaseException();
          Console::WriteLine( e->Message );
          }

          On my test, w->Message == "The system cannot find the file specified". Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          R Offline
          R Offline
          rover_boy
          wrote on last edited by
          #4

          Thank you for your reply, that fixed my problem

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups