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

  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
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    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)
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    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.

  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, 02:28 PM