home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!vnet.ibm.com
- From: fattire@vnet.ibm.com (BJ Hargrave)
- Message-ID: <19920813.054753.507@almaden.ibm.com>
- Date: Thu, 13 Aug 92 08:46:23 EDT
- Newsgroups: comp.os.os2.programmer
- Subject: Re: DosExecPgm Args Question
- News-Software: UReply 3.0
- References: <13AUG199208152210@lims01.lerc.nasa.gov>
- Lines: 30
-
- 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.
- >
- >Well, that arg to DosExecPGm is typedef'ed as "char *PSZ", so I'm a little
- >lost on how it points to more than one string. I have tried a few of what
- >I thought were possibilities, but no luck.
- >
- >Will someone post a code fragment which shows the correct way to load the
- >argument string for DosExecPgm?
-
- 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!
-
- -----------------------------------------------------------------------
- BJ Hargrave Internet: fattire@vnet.ibm.com
- Boca Raton, FL IBMIPNet: bjhar@bjhar.bocaraton.ibm.com
-