home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / os2 / programm / 4197 < 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.081512.393@almaden.ibm.com>
  4. Date: Thu, 13 Aug 92 11:09:25 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.             <19920813.054753.507@almaden.ibm.com>
  10. Lines: 28
  11.  
  12. In <19920813.054753.507@almaden.ibm.com> BJ Hargrave writes:
  13. >PSZ buff = "C:\\OS2\\CMD.EXE\0/C Echo Hello!";
  14. >
  15. >rc = DosExecPgm ( NULL,                 /* Object name buffer         */
  16. >                  0,                    /* len of object name buffer  */
  17. >                  EXEC_SYNC,            /* execute synchronously      */
  18. >                  buff,                 /* arguments                  */
  19. >                  NULL,                 /* environment                */
  20. >                  (PRESULTCODES)&exec_rc,       /* return codes       */
  21. >                  buff );               /* program to execute         */
  22. >
  23. >Notice the \0 after the program name. The last argument to DosExecPgm
  24. >uses the first SZ from buff for the program name and 4th argument to
  25. >DosExecPgm uses the first SZ as argv<0> and the second SZ as the
  26. >arguments to the program!
  27.  
  28. As was duly noted by another vigilant IBMer, buff should be as follows:
  29.  
  30. PSZ buff = "C:\\OS2\\CMD.EXE\0/C Echo Hello!\0";
  31.                                             ^^
  32. The last \0 is necessary to signal the end of the strings.
  33. A trailing zero byte is added by C, thus buff ens with 2 zero bytes.
  34. The 4th argument to DosExecPgm is a series of SZ's punctuated by a zero
  35. byte.
  36.  
  37. -----------------------------------------------------------------------
  38. BJ Hargrave                     Internet: fattire@vnet.ibm.com
  39. Boca Raton, FL                  IBMIPNet: bjhar@bjhar.bocaraton.ibm.com
  40.