• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

Calling another program or code with my program.

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
0
chinese_bunny
Asked:
chinese_bunny
  • 3
3 Solutions
 
AxterCommented:
Hi chinese_bunny,
> >which i can call and external executable in my code?
Sure,
You can use system or WinExec API function

David Maisonave :-)
Cheers!
0
 
AxterCommented:
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.
0
 
AxterCommented:
Example:

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

#include <windows.h>

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

     system("pause");
     return 0;
}
0
 
chinese_bunnyAuthor Commented:
thank you <333
much appreciated!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now