Invoke a function from another running program (EXE) in C/C++

This is a discussion on Invoke a function from another running program (EXE) in C/C++ within the C++ Programming forums, part of the General Programming Boards category; i have a doubt in C++. lets asume A.exe is running and it has two functions A() and B(). i ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    1

    Invoke a function from another running program (EXE) in C/C++

    i have a doubt in C++. lets asume A.exe is running and it has two functions A() and B(). i have another program B.exe, which needs to call some functions say A() in A.exe (which is already running).

    how can we achieve this, what concept we need to use??

    if u have some sample code, or tutorial or forums link, give me those reference.

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,474
    You can place the A function in the dll and use it in both applications

    Or you can build an A application as COM-server and B as COM client (on Windows)
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,453
    Or just put A() in it's own library (DLL or LIB), and then link to it from both applications.

    Or if A() is small, simply copy and paste the source code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    17
    Or if you mean you want your second program to interact with an object instance in your first program, you'll need to define some kind of interface.

    This could be as simple as a file which is periodically checked by the first application or as complicated as a pipe or tcp/ip communication. What you use would largely be dependent on the relative program locations.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  2. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  3. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  4. Replies: 10
    Last Post: 04-07-2008, 09:14 AM
  5. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 01:28 PM

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