How to run an another app from C++?

This is a discussion on How to run an another app from C++? within the C++ Programming forums, part of the General Programming Boards category; Greetings! I'm doing well with my program, and an another problem occured. How can I run an another app from ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    105

    How to run an another app from C++?

    Greetings!

    I'm doing well with my program, and an another problem occured.
    How can I run an another app from my program?
    For Example I'd like to run excel, with a path parameter.

    I tried the
    Code:
    execlp("c:\\Program Files\\Microsoft Office\\Office10\\Excel.exe",dataBuffer);
    code, but I get an exception, and of course except does not run.
    Is there any other function to do this?

    Thanks again
    Han

  2. #2
    poiu
    Guest
    Does Excel take the parameter when entered at the prompt?

    http://faq.cprogramming.com/cgi-bin/...&id=1043284392

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    105
    So I keep trying and trying...
    Here's my next try:
    Code:
    Variant V  = Variant::CreateObject("Excel.Application");
      V.OlePropertySet("Visible", true);
      V.OleFunction("Quit");
      V = Unassigned;

    This code actually DOES run Excel. So my next task is to get it the necessarry parameters. Suggestions? Ideas?

    Thx
    Han

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    23
    Use ShellExecuteEx, and pass in LPSHELLEXECUTEINFO struct which contain your parameters.

  5. #5
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Use ShellExecute and have it open the excel file that is given.

    ShellExecute(hwnd, "open", databuffer, NULL, SW_SHOWNORMAL);


    hwnd is the handle of your window

    databuffer contains the full path and file name

    SW_SHOWNORMAL can be changed to any other of the predefined constants. Whatever you want basically.

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    105
    It works!
    Thanks a lot!

    But it isn't over yet

    My next question is about Visual Basic, sorry for asking it here. But there are just so many helpful people. Some of you surely knows VB in Excel.
    So my next question is:
    How can I close excel in an excel macro?

    Han

  7. #7
    Registered User
    Join Date
    Apr 2003
    Posts
    23
    Try your luck at www.visualbasicforum.com
    Merc

  8. #8
    Registered User
    Join Date
    Mar 2003
    Posts
    105
    I changed my mind about closing excel from the inside. Now I'll close Excel from my C++ program. I'll set a timer to an interval, which is surely longer than the time needed to do the Excel macro functions. But I haven't found in the help or on this side anything about closing a program, which was opened by "Shellexecute".
    How should I do that?

    Han

  9. #9
    Registered User
    Join Date
    Mar 2003
    Posts
    105

    App opening not working.. Why?

    Greetings!

    I'm stuck again with app running.

    I made my application run Excel with the required parameters, and it works very well. The app is now classified "complete" -at least that was what I've thought before making a real app from my program code.

    When I chose the "make" option, an exe file was created -my app- and I began testing it. It turned out, that it somehow does NOT run Excel when required. Why is that? I use the ShellExecute you suggested me. When running from the builder it DOES work. Why doesn't it work, when I run it from the exe file?

    Thx
    Han

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, 08:11 AM
  2. Using C++ to run a Console APP?
    By anon2222 in forum C++ Programming
    Replies: 4
    Last Post: 01-10-2006, 08:07 AM
  3. Stand alone app and .dll's
    By earth_angel in forum Windows Programming
    Replies: 4
    Last Post: 08-08-2005, 02:05 PM
  4. best program to start
    By gooddevil in forum Networking/Device Communication
    Replies: 4
    Last Post: 05-28-2004, 06:56 PM
  5. Need help migrating console app to windows app
    By DelphiGuy in forum C++ Programming
    Replies: 1
    Last Post: 03-14-2004, 07:05 PM

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