home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / os2 / programm / 4209 < prev    next >
Encoding:
Text File  |  1992-08-13  |  1.9 KB  |  46 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!decwrl!ampex!cjensen
  3. From: cjensen@ampex.com (Colin Jensen)
  4. Subject: Re: DosExecPgm Args Question
  5. Message-ID: <1992Aug13.205119.25129@ampex.com>
  6. Sender: usenet@ampex.com (News Poster)
  7. Nntp-Posting-Host: mer-s4-14
  8. Organization: Ampex Corporation, Redwood City CA
  9. References: <13AUG199208152210@lims01.lerc.nasa.gov> <19920813.054753.507@almaden.ibm.com>
  10. Date: Thu, 13 Aug 1992 20:51:19 GMT
  11. Lines: 33
  12.  
  13. In article <19920813.054753.507@almaden.ibm.com> fattire@vnet.ibm.com (BJ Hargrave) writes:
  14. >In <13AUG199208152210@lims01.lerc.nasa.gov> Andy Brush @Sverdrup writes:
  15. >>I'm trying to DosExecPgm a program that requires command-line switches.
  16. >>The docs say that these args are placed in a "pointer to zero-terminated
  17. >>string*s*", and passed to the function.
  18. >
  19. >PSZ buff = "C:\\OS2\\CMD.EXE\0/C Echo Hello!";
  20. >
  21. >rc = DosExecPgm ( NULL,                 /* Object name buffer         */
  22. >                  0,                    /* len of object name buffer  */
  23. >                  EXEC_SYNC,            /* execute synchronously      */
  24. >                  buff,                 /* arguments                  */
  25. >                  NULL,                 /* environment                */
  26. >                  (PRESULTCODES)&exec_rc,       /* return codes       */
  27. >                  buff );               /* program to execute         */
  28. >
  29. >Notice the \0 after the program name. The last argument to DosExecPgm
  30. >uses the first SZ from buff for the program name and 4th argument to
  31. >DosExecPgm uses the first SZ as argv<0> and the second SZ as the
  32. >arguments to the program!
  33.  
  34. Unless I'm confused [common occurance :-)], that should really be
  35.  
  36.     PSZ buff = "C:\\OS2\\CMD.EXE\0/C Echo Hello!\0";
  37.  
  38. [note the extra \0 at the end of the string]
  39.  
  40. I.e. the arguments are laid out contiguously in memory separated by '\0'.
  41. Two '\0' characters are used to mark the end of the argument list.
  42.  
  43. Corrections?
  44. -- 
  45. Colin Jensen (cjensen@ampex.com)
  46.