Running Programs from my app

This is a discussion on Running Programs from my app within the Windows Programming forums, part of the Platform Specific Boards category; Im just learning how to run programs from my application now this code starts solitaire and notepad no problem but ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    57

    Running Programs from my app

    Im just learning how to run programs from my application
    now this code starts solitaire and notepad no problem
    but when i go to run paint it doesnt work (I fear that paint might not be accessable for winexec() ) if that is the case how would i alter the code to go to any directory i wish
    thanks to any one who responds


    void CDay2Dlg::OnRunpgm()
    {
    UpdateData(TRUE);
    CString strPgmName;
    strPgmName = m_strProgToRun;
    strPgmName.MakeUpper();

    if (strPgmName == "PAINT")
    WinExec("pbrush.exe", SW_SHOW);

    if (strPgmName == "NOTEPAD")
    WinExec("notepad.exe", SW_SHOW);

    if (strPgmName == "SOLITAIRE")
    WinExec("sol.exe", SW_SHOW);
    }
    =@-OmegatronO-@=

  2. #2
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    Check out SetCurrentDirectory(), else just:

    char buffer[MAX_PATH];
    char *dir = "C:\SomeDirYouGetFromUser";
    char *ProgName = "SomeProgYouGetFromUser";

    sprintf(buffer, "%s\%s", dir, ProgNam);
    WinExec(buffer, SW_SHOW);

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    591
    Reading the "Teach yourself VC in 21 days" uhu?? Depending on what OS you are using paint might be called something else. In NT 4.0 it is called mspaint.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. non-MFC DLL with MFC app question.
    By Kempelen in forum Windows Programming
    Replies: 10
    Last Post: 08-20-2008, 07:11 AM
  2. Deadlocked App
    By markanderson in forum Linux Programming
    Replies: 2
    Last Post: 10-14-2005, 02:19 PM
  3. How to get a list of all the running programs?
    By Josh Kasten in forum Windows Programming
    Replies: 1
    Last Post: 04-15-2003, 05:12 AM
  4. Running multiple programs
    By Kespoosh in forum C++ Programming
    Replies: 2
    Last Post: 03-17-2003, 03:53 PM
  5. Running programs as Services
    By Unregistered in forum Windows Programming
    Replies: 2
    Last Post: 10-20-2001, 04:17 AM

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