This is the mail archive of the cygwin-xfree@cygwin.com mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: console IO in GUI apps


On Sun, Oct 21, 2001 at 02:21:49PM -0400, huntharo@msu.edu wrote:
>Christopher Faylor <cgf@redhat.com> said:
>>>I would also mention that there is an AttachConsole where you can use
>>>an already existing console, you just have to know the console owner's
>>>PID.
>>
>>The MSDN documentation indicates that AttachConsole is available on
>>Windows XP only.  It's not a generic solution.
>
>Win32's SetStdHandle () will allow us to attach to an already open
>console.  However, we have to get the process id of the launching
>console before we can figure out what console handles we will pass to
>SetStdHandle ().  I've tried looking for functions like
>GetParentProcess (), etc.  but so far I can't find a function that will
>return a handle, or the process id, of the launching process.
>
>Does anyone know of such a function?

Windows doesn't have a generic way of finding the parent.  You can find
this via functions in psapi (NT) or ToolHelp32 (9x).  pinfo.cc in cygwin
does this, as does ps.cc, if you want to look at code.  There are also
various code samples on the internet.

Also, if you are starting the process via cygwin, you can just use
getppid, of course.

I don't think that getting the parent's handle will do you much good,
though.  Once you get it, then what?  You'll be able to attach to a
console on Windows XP.  That's not going to be a very good solution
for some time, though, is it?

cgf


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]