home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / pascal / demoexec.pas next >
Encoding:
Pascal/Delphi Source File  |  1988-08-11  |  1.2 KB  |  55 lines

  1. {*    DEMOEXEC.PAS - demonstration progam for calling C library functions
  2.  *
  3.  *    Microsoft Pascal release 3.32 can call large model C functions.
  4.  *    Please read PASEXEC.INC for more details on interlanguage calling.
  5.  *
  6.  *    To compile and link DEMOEXEC.PAS
  7.  *
  8.  *    pas1 demoexec;
  9.  *    pas2
  10.  *    link demoexec,,,cexec;        (must search CEXEC.LIB)
  11.  *}
  12.  
  13. program demoexec(input,output);
  14.  
  15. {$include : 'pasexec.inc'}
  16.  
  17. var
  18.     i : integer;
  19.     NULL : integer4;
  20.  
  21. value
  22.     NULL := 0;
  23.  
  24. begin
  25.  
  26. {*    invoke command.com with a command line
  27.  *
  28.  *        dir *.pas
  29.  *}
  30.     i := system(ads('dir *.pas'*chr(0)));
  31.     writeln (output,'system return code = ',i);
  32.     writeln (output,' ');
  33.  
  34. {*    invoke a child process
  35.  *
  36.  *        exemod        (display usage line only)
  37.  *}
  38.     i := spawnlp(0,ads('exemod'*chr(0)),ads('exemod'*chr(0)),NULL);
  39.     writeln (output,'spawnlp return code =',i);
  40.     writeln (output,' ');
  41.  
  42. {*    invoke an overlay process (chaining)
  43.  *
  44.  *        exemod demoexec.exe
  45.  *}
  46.     i := spawnlp(_p_overlay,ads('exemod'*chr(0)),ads('exemod'*chr(0)),
  47.              ads('demoexec.exe'*chr(0)),NULL);
  48.  
  49. {*    we should never see this if spawnlp (overlay) is successful
  50.  *}
  51.     writeln (output,'spawnlp return code =',i);
  52.     writeln (output,' ');
  53.  
  54. end.
  55.