home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / CALDOS.ZIP / CALLDOS.C next >
Text File  |  1993-01-14  |  3KB  |  96 lines

  1. #define INCL_DOSSESMGR      /* Session Manager values */
  2. #include <os2.h>
  3. #include <stdio.h>
  4.  
  5. STARTDATA   StartData;    /* Start session data structure */
  6. ULONG       SessID;       /* Session ID (returned) */
  7. PID         pid;          /* Process ID (returned) */
  8. UCHAR       PgmTitle[40]; /* Program title string */
  9. UCHAR       PgmName[80];  /* Program pathname string */
  10. UCHAR       ObjBuf[100];  /* Object buffer */
  11. PSZ         Environ = "DOS_HIGH=1\0DPMI_DOS_API=ENABLED\0DPMI_MEMORY_LIMIT=512\0\
  12. KBD_ALTHOME_BYPASS=1\0MOUSE_EXCLUSIVE_ACCESS=1\0";
  13. APIRET      rc;           /* Return code */
  14.  
  15. main()                         
  16. {
  17.  
  18. /*  Specify the various session start parameters  */
  19.  
  20. StartData.Length = sizeof(STARTDATA);
  21.                        /* Length of STARTDATA structure */
  22.  
  23. StartData.Related = SSF_RELATED_INDEPENDENT;
  24.                        /* Independent session */
  25.  
  26. StartData.FgBg = SSF_FGBG_FORE;
  27.                        /* Start child session in foreground */
  28.  
  29. StartData.TraceOpt = SSF_TRACEOPT_NONE;
  30.                        /* Don't trace session */
  31.  
  32. strcpy(PgmTitle,"DOS Command Prompt");
  33. StartData.PgmTitle = PgmTitle;
  34.                        /* Session Title string */
  35.  
  36. strcpy(PgmName,"COMMAND.COM");
  37. StartData.PgmName = PgmName;
  38.                        /* Program path-name string */
  39.  
  40. StartData.PgmInputs = 0;
  41.                        /* Assume no input arguments need */
  42.                        /*   be passed to the program     */
  43.  
  44. StartData.TermQ = 0;   /* Assume no termination queue */
  45.  
  46. StartData.Environment = Environ;
  47.                        /* Address of environment string */
  48.  
  49. StartData.InheritOpt = SSF_INHERTOPT_SHELL;
  50.                        /* Inherit the Shell's environment */
  51.  
  52. StartData.SessionType = SSF_TYPE_WINDOWEDVDM;
  53.                        /* Start the program in a Windowed DOS session */
  54.  
  55. StartData.IconFile = 0;
  56.                        /* Assume no specific icon file */
  57.                        /*   is provided                */
  58.  
  59. StartData.PgmHandle = 0;
  60.                        /* Do not use the installation file */
  61.  
  62. StartData.PgmControl = SSF_CONTROL_VISIBLE
  63.                          | SSF_CONTROL_MAXIMIZE;
  64.                        /* Start the program as visible */
  65.                        /*   and maximized              */
  66.  
  67. StartData.InitXPos = 30;
  68. StartData.InitYPos = 40;
  69. StartData.InitXSize = 200;    /* Initial window coordinates */
  70. StartData.InitYSize = 140;    /*   and size                 */
  71.  
  72. StartData.Reserved = 0;
  73.                        /* Reserved, must be zero */
  74.  
  75. StartData.ObjectBuffer = ObjBuf;
  76.                        /* Object buffer to hold DosExecPgm */
  77.                        /*   failure causes                 */
  78.  
  79. StartData.ObjectBuffLen = 100;
  80.                        /* Size of object buffer */
  81.  
  82. rc = DosStartSession(&StartData, &SessID, &pid);
  83.                       /* On successful return, the variable  */
  84.                       /*   SessID contains the session ID    */
  85.                       /*   of the new session, and the       */
  86.                       /*   variable PID contains the process */
  87.                       /*   ID of the new process             */
  88.  
  89. if (rc != 0)
  90.   {
  91.     printf("DosStartSession error: return code = %ld", rc);
  92.     return;
  93.   }
  94.  
  95. }
  96.