Calling another program or code with my program.

Posted on 2005-04-13
Last Modified: 2013-11-20
Hi, i have written an MFC program...but one of the functions is handled in another program, which is written in c#.
Is there a way i can integrate thee C# code into my code? or is there an automatic method in which i can call and external executable in my code?

thank you
Question by:chinese_bunny
    LVL 30

    Assisted Solution

    Hi chinese_bunny,
    > >which i can call and external executable in my code?
    You can use system or WinExec API function

    David Maisonave :-)
    LVL 30

    Assisted Solution

    There are several methods for launching another program from one program.
    You can use _spawn(), _exec(), system(), WinExec(), ShellExecute(), ShellExecuteEx(), and CreateProcess().

    The system() function is a more portable function.
    WinExec(), ShellExecute(), ShellExecuteEx(), and CreateProcess() are unique to Windows programming. All four windows functions allow for launching an application in the background (window-hidden).

    The WinExec() is the easiest of the four to use. It only takes two arguments, however MS recommends using the CreateProcess() instead of WinExec on all 32-bit programs.
    LVL 30

    Accepted Solution


    #include "stdafx.h"
    #include <stdlib.h>

    #include <windows.h>

    int main(int argc, char* argv[])
         WinExec("notepad.exe", SW_SHOW);

         return 0;

    Author Comment

    thank you <333
    much appreciated!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
    Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now