Article View: comp.os.os2.programmer
Article #793Re: DosExecPgm Args Question
From: BJ Hargrave
Date: Thu, 13 Aug 1992 15:09
Date: Thu, 13 Aug 1992 15:09
28 lines
1858 bytes
1858 bytes
In <19920813.054753.507@almaden.ibm.com> BJ Hargrave writes:
>PSZ buff = "C:\\OS2\\CMD.EXE\0/C Echo Hello!";
>
>rc = DosExecPgm ( NULL, /* Object name buffer */
> 0, /* len of object name buffer */
> EXEC_SYNC, /* execute synchronously */
> buff, /* arguments */
> NULL, /* environment */
> (PRESULTCODES)&exec_rc, /* return codes */
> buff ); /* program to execute */
>
>Notice the \0 after the program name. The last argument to DosExecPgm
>uses the first SZ from buff for the program name and 4th argument to
>DosExecPgm uses the first SZ as argv<0> and the second SZ as the
>arguments to the program!
As was duly noted by another vigilant IBMer, buff should be as follows:
PSZ buff = "C:\\OS2\\CMD.EXE\0/C Echo Hello!\0";
^^
The last \0 is necessary to signal the end of the strings.
A trailing zero byte is added by C, thus buff ens with 2 zero bytes.
The 4th argument to DosExecPgm is a series of SZ's punctuated by a zero
byte.
-----------------------------------------------------------------------
BJ Hargrave Internet: fattire@vnet.ibm.com
Boca Raton, FL IBMIPNet: bjhar@bjhar.bocaraton.ibm.com
Technical Details
Message-ID:
<19920813.081512.393@almaden.ibm.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!vnet.ibm.comReferences:
<13AUG199208152210@lims01.lerc.nasa.gov> <19920813.054753.507@almaden.ibm.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!vnet.ibm.com
From: fattire@vnet.ibm.com (BJ Hargrave)
Message-ID: <19920813.081512.393@almaden.ibm.com>
Date: Thu, 13 Aug 92 11:09:25 EDT
Newsgroups: comp.os.os2.programmer
Subject: Re: DosExecPgm Args Question
News-Software: UReply 3.0
References: <13AUG199208152210@lims01.lerc.nasa.gov>
<19920813.054753.507@almaden.ibm.com>
Lines: 28