Article View: comp.os.ms-windows.programmer.win32
Article #2187Re: Running a PIF file using CreateProcess in an allocated console window
From: Olof Lagerkvist
Date: Mon, 26 Apr 2004 15:27
Date: Mon, 26 Apr 2004 15:27
52 lines
3378 bytes
3378 bytes
Ran wrote:
> Hello,
>
> I am trying to find a way to execute a pif file within the context of
> my own application's console using AllocConsole.
>
> My basic need is to have the console in my context so I can use the
> console API's AND I must use the pif parameters for EMS, XMS, and a
> few other parameters.
>
> Is there a way to do this ? Is there a way around ?
>
> For example, try running "start /b XX.pif"
>
> I am getting an error message
>
> The NTVDM CPU has encountered an illegal instruction.
> and get the Close Ignore buttons.
>
> This is not related to any problems in the DOS application.
>
> If I use CREATE_NEW_CONSOLE in the creation flags, ofcourse everything
> works,
> but it is open in a new window. in the allocated console window I
> always get this GPF.
>
> Is there a way to get the console window in my context after the OS
> created it ?
>
> I can change _default.pif and just execute cmd.exe but I do not want
> to be dependant on _default.pif because of multiple executions issue.
> _default.pif is is hardcoded into ntvdm.exe.
> How can I allocconsole, run CMD with PIF settings ? and no
> _default.pif?
After AllocConsole() you need to get the handles to the console I/O and
set them as standard input/output/error so that the new process can
inherit the console I/O handles.
Use CreateFile("conin$", ...) and CreateFile("conout$", ...) as
described in CreateFile() documentation. Make sure the handles get
inheritable. Then pass the handles you get to SetStdHandle().
As an alternative you can skip the three SetStdHandle() calls and
instead pass the handles to the new process in the STARTUPINFO structure
passed to CreateProcess().
--
Olof Lagerkvist
ICQ: 724451
Web page: http://here.is/olof
Technical Details
Message-ID:
<xT9jc.57273$mU6.234924@newsb.telia.net>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!news-stoc.telia.net!217.209.241.210.MISMATCH!news-stod.telia.net!telia.net!masternews.telia.net.!newsb.telia.net.POSTED!not-for-mailReferences:
<2d73b65b.0404260615.4d28b9aa@posting.google.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 113dfb,96238a6b4094de6b X-Google-Thread: f94dd,5caf29689b7aca92 X-Google-Thread: 104093,1923a51ef2371e4f X-Google-Thread: 110c1b,47b2e465e7d83716 X-Google-Thread: f645d,311346bbd5e70fc1 X-Google-Attributes: gid113dfb,gidf94dd,gid104093,gid110c1b,gidf645d,public X-Google-ArrivalTime: 2004-04-26 08:27:25 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!news-stoc.telia.net!217.209.241.210.MISMATCH!news-stod.telia.net!telia.net!masternews.telia.net.!newsb.telia.net.POSTED!not-for-mail From: Olof Lagerkvist <no@email.address> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: sv, da, nb, en MIME-Version: 1.0 Newsgroups: comp.os.ms-windows.programmer.win32,borland.public.delphi.nativeapi,microsoft.public.vb.winapi,microsoft.public.win32.programmer.ui,comp.lang.basic.visual Subject: Re: Running a PIF file using CreateProcess in an allocated console window References: <2d73b65b.0404260615.4d28b9aa@posting.google.com> In-Reply-To: <2d73b65b.0404260615.4d28b9aa@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Lines: 53 Message-ID: <xT9jc.57273$mU6.234924@newsb.telia.net> Date: Mon, 26 Apr 2004 15:27:25 GMT NNTP-Posting-Host: 195.252.34.73 X-Complaints-To: abuse@telia.com X-Trace: newsb.telia.net 1082993245 195.252.34.73 (Mon, 26 Apr 2004 17:27:25 CEST) NNTP-Posting-Date: Mon, 26 Apr 2004 17:27:25 CEST Organization: Telia Internet