home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.os2.programmer
- Path: 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
-
- 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)
-