home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / startvio.zip / vio / vio.c < prev    next >
C/C++ Source or Header  |  1998-02-20  |  2KB  |  85 lines

  1. #define  INCL_DOSPROCESS
  2. #define  INCL_DOSSESMGR
  3. #define  INCL_WINSHELLDATA
  4. #include <os2.h>
  5. #include <stdlib.h>
  6.  
  7. char   pels[] =                 /* w,h */
  8.             {  8,8,    8,8,                     /* 0, 1,           */
  9.                8,8,    6,10,   8,10,   8,12,    /* 2, 3, 4, 5,     */
  10.                6,14,   8,14,   7,15,   8,16,    /* 6, 7, 8, 9,     */
  11.                12,16,  8,18,  10,18,  12,20,    /* 10, 11, 12, 13, */
  12.                12,22,  7,25,  12,30       };    /* 14, 15, 16      */
  13.  
  14. int    p = 0;
  15.  
  16. CHAR   cs[2];
  17. ULONG  ccs = sizeof(cs);
  18.  
  19. char  *Shield       = "Shield";
  20. char  *FontSize     = "~Font Size...";
  21.  
  22. char  *pgmname      = "CMD.EXE";
  23. char  *title        = "CMD.EXE";
  24. char   cmdline[512] = { '/','K',0 };
  25.  
  26. char   failer[CCHMAXPATH];
  27.  
  28. STARTDATA sd;
  29. ULONG     sid;
  30. PID       pid;
  31.  
  32. /* syntax: VIO n "title" command-line */
  33.  
  34. int main( int argc, char *argv[] )
  35. {
  36.   APIRET rc;
  37.  
  38.   WinInitialize(0);
  39.  
  40.   if ( argc > 1 ) { p = atoi(argv[1]); if ( p > 16 ) p = 0; }
  41.  
  42.   if ( argc > 2 ) { if ( *(argv[2]) != 0 ) title = argv[2]; }
  43.  
  44.   if ( argc > 3 ) { int i; char *a, *b;
  45.                     cmdline[0] = ' ';
  46.                     a = cmdline;
  47.                     for ( i = 3; i < argc; i++ )
  48.                     { for ( b = argv[i]; *b; *a++ = *b++ ); *a++ = ' '; }
  49.                     *(--a) = 0;
  50.                   }
  51.  
  52.   sd.Length         = sizeof(sd);
  53.   sd.Related        = SSF_RELATED_INDEPENDENT;
  54.   sd.FgBg           = SSF_FGBG_FORE;
  55.   sd.TraceOpt       = SSF_TRACEOPT_NONE;
  56.   sd.PgmTitle       = title;
  57.   sd.PgmName        = pgmname;
  58.   sd.PgmInputs      = cmdline;
  59.   sd.TermQ          = 0;
  60.   sd.Environment    = 0;
  61.   sd.InheritOpt     = SSF_INHERTOPT_SHELL;
  62.   sd.SessionType    = SSF_TYPE_WINDOWABLEVIO;
  63.   sd.IconFile       = 0;
  64.   sd.PgmHandle      = 0;
  65.   sd.PgmControl     = SSF_CONTROL_VISIBLE;
  66.   sd.InitXPos       = 0;
  67.   sd.InitYPos       = 0;
  68.   sd.InitXSize      = 0;
  69.   sd.InitYSize      = 0;
  70.   sd.Reserved       = 0;
  71.   sd.ObjectBuffer   = failer;
  72.   sd.ObjectBuffLen  = sizeof(failer);
  73.  
  74.   if ( PrfQueryProfileData( HINI_USERPROFILE, Shield, FontSize, cs, &ccs ) &&
  75.        PrfWriteProfileData( HINI_USERPROFILE, Shield, FontSize, pels+(p*2), ccs ) )
  76.   {
  77.     rc = DosStartSession( &sd, &sid, &pid );
  78.     DosSleep(500);
  79.  
  80.     PrfWriteProfileData( HINI_USERPROFILE, Shield, FontSize, cs, ccs );
  81.   }
  82.  
  83.   return rc;
  84. }
  85.