Re: Get parent's console?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: James Brown (remove_james_dot_brown7_at_virgin_dot_net)
Date: 01/25/05


Date: Tue, 25 Jan 2005 18:05:53 -0000

David,
there isn't really any neat way to do this. The best approach
still seems to be using two executables - a console exe, which you
rename "prog.com", and a windows exe, called "prog.exe"...run
via the command-line, prog.com gets executed in preference to prog.exe
run via the gui....just use a short-cut to the exe.

I struggled with AttachConsole under XP, the problem seemed to be
that the C-runtime stdio handles weren't set correctly, so things like
printf / fgets just didn't work properly.

-- 
James
---
www.catch22.net
Free win32 software, sourcecode and tutorials
-----
Please de-spam my email address before replying.
"David Olsson" <david.olsson@vimio.com> wrote in message 
news:OAuzGFuAFHA.4044@TK2MSFTNGP10.phx.gbl...
> Hi!
>
> I'm not sure if this is the correct group to post this question to but my 
> question doesn't fit very well in any group I've found. Anyway, here 
> goes...
>
> I would like to be able to attach a process to the console of the process 
> that started the process. If, for example, my process is started using the 
> command line (CDM.EXE), I would like to be able to access the standard in, 
> out and error file handles of that console. This is of course exactly what 
> happens if I compile and link my application as a console application. But 
> if I compile and link my application as a console application, I (of 
> course) get a console even if my application is started, for example, by 
> clicking a shortcut to it. It all boils down to that I want a console only 
> if the application has been started through a console. I've tried with the 
> AllocConsole() API function but it creates a new console window.
>
> Is there any way to accomplish want I want? I am very grateful for any 
> tips!
> / David Olsson 


Relevant Pages

  • Console Application Testing
    ... I'm going through a few code examples that are demonstrated using a Console ... for some reason I am unable to move forward with them. ... I managed to compile my ... application into an EXE once in the past, but I don't recall how I did this. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Console Windows Forms hybrid
    ... In the console application, if no parameters are passed on the ... just launch the EXE and then exit. ... it runs as a console app. ... This is workable - I have a little shim launcher program whose ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Strange behavour of Process
    ... Did the all the EXE are of Console Application? ... Have you tried to write a test console application for a test to see if ... Microsoft Online Partner Support ...
    (microsoft.public.dotnet.framework)
  • Console window switch - vc2005 C++/clr/MASM project
    ... I have a project that mixes C++/clr and MASM in a single ... The exe starts with a console window which I don't want. ... I think it boils down to a linker switch - IIRC, ...
    (microsoft.public.vstudio.general)
  • Why do I get error 6 (The Handle is Invalid) trying to WriteFile to STDOUT from VB 6 exe?
    ... I create the following VB 6 app to write to STDOUT. ... I run the exe from a command line. ... I'm assuming somehow my vb app can't see the console it is being run from. ... I'd expect this failure running from the IDE but not from the command line. ...
    (microsoft.public.vb.winapi)