home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / os2 / programm / 4196 < prev    next >
Encoding:
Internet Message Format  |  1992-08-13  |  1.8 KB

  1. Path: sparky!uunet!vnet.ibm.com
  2. From: fattire@vnet.ibm.com (BJ Hargrave)
  3. Message-ID: <19920813.054753.507@almaden.ibm.com>
  4. Date: Thu, 13 Aug 92 08:46:23 EDT
  5. Newsgroups: comp.os.os2.programmer
  6. Subject: Re: DosExecPgm Args Question
  7. News-Software: UReply 3.0
  8. References: <13AUG199208152210@lims01.lerc.nasa.gov>
  9. Lines: 30
  10.  
  11. In <13AUG199208152210@lims01.lerc.nasa.gov> Andy Brush @Sverdrup writes:
  12. >I'm trying to DosExecPgm a program that requires command-line switches.
  13. >The docs say that these args are placed in a "pointer to zero-terminated
  14. >string*s*", and passed to the function.
  15. >
  16. >Well, that arg to DosExecPGm is typedef'ed as "char *PSZ", so I'm a little
  17. >lost on how it points to more than one string.  I have tried a few of what
  18. >I thought were possibilities, but no luck.
  19. >
  20. >Will someone post a code fragment which shows the correct way to load the
  21. >argument string for DosExecPgm?
  22.  
  23. PSZ buff = "C:\\OS2\\CMD.EXE\0/C Echo Hello!";
  24.  
  25. rc = DosExecPgm ( NULL,                 /* Object name buffer         */
  26.                   0,                    /* len of object name buffer  */
  27.                   EXEC_SYNC,            /* execute synchronously      */
  28.                   buff,                 /* arguments                  */
  29.                   NULL,                 /* environment                */
  30.                   (PRESULTCODES)&exec_rc,       /* return codes       */
  31.                   buff );               /* program to execute         */
  32.  
  33. Notice the \0 after the program name. The last argument to DosExecPgm
  34. uses the first SZ from buff for the program name and 4th argument to
  35. DosExecPgm uses the first SZ as argv<0> and the second SZ as the
  36. arguments to the program!
  37.  
  38. -----------------------------------------------------------------------
  39. BJ Hargrave                     Internet: fattire@vnet.ibm.com
  40. Boca Raton, FL                  IBMIPNet: bjhar@bjhar.bocaraton.ibm.com
  41.