🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #791

Re: DosExecPgm Args Question

#791
From: BJ Hargrave
Date: Thu, 13 Aug 1992 12:46
30 lines
1928 bytes
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
Technical Details
Message-ID: <19920813.054753.507@almaden.ibm.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!vnet.ibm.com
References: <13AUG199208152210@lims01.lerc.nasa.gov>

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.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