Thread: get window handle of system()?

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    8

    get window handle of system()?

    I'm sorry if this is a stupid question; I am attempting to get the window handle of a program that's executed using the system() command, i.e. something like:

    Code:
    int pid = fork();
    if (fork == 0) {
        system("program name")
    } else {
        ...
    }

    Is this possible? would it be possible to do so if I used one of the exec() functions instead?

    Thanks! (using Kubuntu 12 btw)



    EDIT: ehh..I think it might be better to ask this on linuxforums, now that I think about it...
    Last edited by dsab123; 06-28-2012 at 04:05 PM.

  2. #2
    Registered User
    Join Date
    May 2012
    Posts
    8
    For anyone else who has/had this problem, you can't do it with system(), because in system(3): execute shell command - Linux man page, the program is run in the shell, which (I think) makes it impossible to get the window handle, or ID

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    Moved to Linux Programming forum.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How get system window handle ?
    By theclem35 in forum C Programming
    Replies: 15
    Last Post: 06-19-2011, 08:04 AM
  2. Getting window handle from HDC
    By maxorator in forum Windows Programming
    Replies: 2
    Last Post: 01-02-2007, 03:07 PM
  3. PID from window handle.
    By Brian in forum Windows Programming
    Replies: 0
    Last Post: 11-23-2004, 07:42 AM
  4. Max Window By Handle
    By Geolingo in forum Windows Programming
    Replies: 1
    Last Post: 08-29-2003, 06:05 PM
  5. Retrieving the window handle of a window a control resides in
    By -leech- in forum Windows Programming
    Replies: 7
    Last Post: 08-09-2003, 08:55 AM

Tags for this Thread