Article View: comp.os.os2.programmer
Article #810Re: DosExecPgm Args Question
From: Colin Jensen
Date: Thu, 13 Aug 1992 20:51
Date: Thu, 13 Aug 1992 20:51
33 lines
2022 bytes
2022 bytes
In article <19920813.054753.507@almaden.ibm.com> fattire@vnet.ibm.com (BJ Hargrave) writes:
>In <13AUG199208152210@lims01.lerc.nasa.gov> Andy Brush @Sverdrup writes:
>>I'm trying to DosExecPgm a program that requires command-line switches.
>>The docs say that these args are placed in a "pointer to zero-terminated
>>string*s*", and passed to the function.
>
>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!
Unless I'm confused [common occurance :-)], that should really be
PSZ buff = "C:\\OS2\\CMD.EXE\0/C Echo Hello!\0";
[note the extra \0 at the end of the string]
I.e. the arguments are laid out contiguously in memory separated by '\0'.
Two '\0' characters are used to mark the end of the argument list.
Corrections?
--
Colin Jensen (cjensen@ampex.com)
Technical Details
Message-ID:
<1992Aug13.205119.25129@ampex.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!decwrl!ampex!cjensenReferences:
<13AUG199208152210@lims01.lerc.nasa.gov> <19920813.054753.507@almaden.ibm.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.os2.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!decwrl!ampex!cjensen From: cjensen@ampex.com (Colin Jensen) Subject: Re: DosExecPgm Args Question Message-ID: <1992Aug13.205119.25129@ampex.com> Sender: usenet@ampex.com (News Poster) Nntp-Posting-Host: mer-s4-14 Organization: Ampex Corporation, Redwood City CA References: <13AUG199208152210@lims01.lerc.nasa.gov> <19920813.054753.507@almaden.ibm.com> Date: Thu, 13 Aug 1992 20:51:19 GMT Lines: 33