Interaction between two programs

Discussion in 'C++' started by Denis Remezov, May 20, 2004.

  1. Sean wrote:
    >
    > I'm sure this might be a simple questions, but here it goes anyway. I
    > am trying to do a 'front end' to a program. For example I have a
    > program that doesn't take command line arguments, but prompts the user
    > for input every time it is run, ie. Enter your name:
    >
    > I want to run a program that will automatically type the name into
    > that field. I just don't really know where to start. Is this
    > suppossed to be a spawn or an exec? I saw something about pipes, but
    > didn't quite get it. Please explain for me.
    >
    > This is NOT for a class, just trying to learn how to do things



    You could possibly make the use of the following:

    Both C++ and C define three "standard streams": stdin, stdout and stderr.
    The type of these expressions is FILE*, and they are required (I think;
    need to double-check) to be open at the program start-up. See <stdio.h>
    or <cstdio>.
    The C++ objects cin, cout and cerr use the respective standard streams as well.

    Now, what is hiding behind each of the standard stream depends on the way
    the program was started (they could be attached to the terminal, to files,
    to streams of another program, etc.). This part, however, is indeed system
    dependent. One thing that is standard is the system() function, but its
    behaviour is again system dependent.

    Denis
     
    Denis Remezov, May 20, 2004
    #1
    1. Advertising

  2. Denis Remezov

    Sean Guest

    I'm sure this might be a simple questions, but here it goes anyway. I
    am trying to do a 'front end' to a program. For example I have a
    program that doesn't take command line arguments, but prompts the user
    for input every time it is run, ie. Enter your name:

    I want to run a program that will automatically type the name into
    that field. I just don't really know where to start. Is this
    suppossed to be a spawn or an exec? I saw something about pipes, but
    didn't quite get it. Please explain for me.

    This is NOT for a class, just trying to learn how to do things
     
    Sean, May 20, 2004
    #2
    1. Advertising

  3. Denis Remezov

    bartek Guest

    (Sean) wrote in news:74cb4ff3.0405201251.27d1c150
    @posting.google.com:

    > I'm sure this might be a simple questions, but here it goes anyway. I
    > am trying to do a 'front end' to a program. For example I have a
    > program that doesn't take command line arguments, but prompts the user
    > for input every time it is run, ie. Enter your name:
    >
    > I want to run a program that will automatically type the name into
    > that field. I just don't really know where to start. Is this
    > suppossed to be a spawn or an exec? I saw something about pipes, but
    > didn't quite get it. Please explain for me.
    >
    > This is NOT for a class, just trying to learn how to do things


    Your question has nothing to do with C++. It is off topic in this
    newsgroup.

    It is also very platform specific, though you don't even specify what
    platform implementation you're interested in.

    For unix, see news:comp.unix.programmer
    Ask about pipe/popen, fork and exec.

    For windows, see news:comp.os.ms-windows.programmer.*
    Ask about CreatePipe, CreateProcess etc...

    Cheers.
     
    bartek, May 20, 2004
    #3
  4. Denis Remezov

    JKop Guest

    Sean posted:

    > I'm sure this might be a simple questions, but here it goes anyway. I
    > am trying to do a 'front end' to a program. For example I have a
    > program that doesn't take command line arguments, but prompts the user
    > for input every time it is run, ie. Enter your name:
    >
    > I want to run a program that will automatically type the name into
    > that field. I just don't really know where to start. Is this
    > suppossed to be a spawn or an exec? I saw something about pipes, but
    > didn't quite get it. Please explain for me.
    >
    > This is NOT for a class, just trying to learn how to do things
    >



    This is a C++ newsgroup, no more no less. We conversate about C++ here. We
    don't mention a word about platforms. You may find this a bit hard to
    imagine, but think about things like: Encrypting Data, Encoding an MP3. Both
    these processes are platform independant.


    C++ is used to write programs for anything. A C++ compiler generates machine
    code, which can be a Windows program, or the interface for your brand new
    microwave, or the menus on your mobile phone.
    Therefore, we don't talk about two programs running at once here in this
    newsgroup. You're going to have to go to a very platform specific newsgroup
    to talk about this. I myself am familiar with Win32 programming, so... if
    the programs you're writing are Win32, then here's one way of going about
    it:

    First make your first program, into which you enter your name. You're done
    with the first program now.

    The trick is in writing the second program. I suggest that you use the
    function "FindWindow" or a similar Win32API function that can be used to
    obtain some sort of handle to the other program. Once you've got some sort
    of handle, you use more Win32API functions to send information and/or
    manipulate the first program. You'll most likely use the Win32 function
    "SendMessage" for this.

    Further questions on this subject to:

    News Server: msnews.microsoft.com
    Newsgroup: microsoft.public.win32.programmer.kernel

    Note that the above newsgroup isn't language specific, so don't post any
    code. People will simply tell you which Win32 function to use and in what
    way. Make sure you tell them it's a console application.


    Hope that helps.


    -JKop
     
    JKop, May 20, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    12
    Views:
    1,672
    Dave Thompson
    Jan 10, 2005
  2. Harayasu
    Replies:
    3
    Views:
    607
    moongateclimber
    Aug 21, 2003
  3. Coca
    Replies:
    7
    Views:
    754
    Aidan Grey
    Aug 24, 2004
  4. Replies:
    18
    Views:
    638
    Dave Thompson
    Jan 10, 2005
  5. Ewout

    Interaction between two strings

    Ewout, Nov 10, 2003, in forum: Perl Misc
    Replies:
    6
    Views:
    112
    Austin P. So (Hae Jin)
    Nov 11, 2003
Loading...

Share This Page