home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / strtvd.c < prev    next >
C/C++ Source or Header  |  1993-06-01  |  3KB  |  102 lines

  1. /*
  2.  *Very simple straight forward utility for using WinCreateObject to create
  3.  *Dos program icons in the NOWHERE folder for launching a DOS session with
  4.  *specific settings.  Could also be used to create WINOS2 objects so that
  5.  *seamless windows could be achieved.
  6.  *
  7.  *Property Bryan Walker DBA WalkerWerks
  8.  *Placed in the public domain.
  9.  */
  10. #define INCL_BASE
  11. #define INCL_PM
  12. #define INCL_WINWORKPLACE
  13. #define INCL_WINMESSAGEMGR
  14. #include <os2.h>
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17.  
  18.  
  19. SHORT Help(VOID)
  20. {
  21.    printf("Strt_Vdm parameters:\n") ;
  22.    printf("/Iimagefile\n") ;
  23.    printf("/Ttitle\n") ;
  24.    printf("/Sadditional Settings\n") ;
  25.    printf("/W w for windowed or f for fullscreen\n") ;
  26.    printf("\nAdditional Settings and window setting are optional,\n") ;
  27.    printf("imagefile and title are required\n") ;
  28.    return 0 ;
  29. }
  30. main(int argc, char *argv[], char *envp[])
  31. {
  32. HAB hab ;
  33. HMQ hmq ;
  34. CHAR title[80], image[256], settings[1024], addsetup[512], wintxt[30] ;
  35. SHORT x, setup = FALSE, Window = FALSE ;
  36.  
  37. printf("\nStart VDM DOS Session Command Line Utility\n") ;
  38. printf("Brought to you by WalkerWerks (901) 683-3770\n") ;
  39. if(argc < 3)
  40.     return Help() ;
  41.  
  42. for(x = 1 ; x < argc ; x++)
  43.    {
  44.     if(*(argv[x] + 1)=='H' || *(argv[x] + 1) == 'h')
  45.         return Help() ;
  46.     if(*(argv[x] + 1)=='I' || *(argv[x] + 1) == 'i')
  47.         {
  48.         if( *(argv[x]+2) == '*')
  49.             image[0] = 0 ;
  50.         else
  51.             sprintf(image, "SET DOS_STARTUP_DRIVE=%s", argv[x] + 2) ;
  52.         }
  53.     else if(*(argv[x] + 1)=='T' || *(argv[x] + 1)=='t')
  54.         sprintf(title, "%s", argv[x] + 2) ;
  55.     else if(*(argv[x] + 1)=='S' || *(argv[x] + 1)=='s')
  56.         {
  57.         setup = TRUE ;
  58.         sprintf(addsetup, "%s", argv[x] + 2 );
  59.         }
  60.     else if( *(argv[x] + 1) == 'W' || *(argv[x] + 1) == 'w')
  61.         {
  62.         Window = TRUE ;
  63.         if(*(argv[x]+2) == 'w' || *(argv[x]+2) == 'W')
  64.             sprintf(wintxt, "WINDOWEDVDM") ;
  65.         else
  66.             sprintf(wintxt, "VDM") ;
  67.         }
  68.     else
  69.         return Help() ;
  70.     }
  71.  
  72. if(setup && argc <= 3)
  73.     return Help() ;
  74.  
  75. if( Window == FALSE )
  76.     sprintf(wintxt, "WINDOWEDVDM") ;
  77.  
  78. sprintf(settings, "EXENAME=*;PROGTYPE=%s;%s;OPEN=DEFAULT;", wintxt, image) ;
  79. if(setup)
  80.     strcat(settings, addsetup) ;
  81.  
  82. /*Initialize our connection to PM*/
  83. hab = WinInitialize(0);
  84. hmq = WinCreateMsgQueue(hab, 0) ;
  85.  
  86. /*Create an object in the hidden folder that is opened by default.  Replacing
  87.   the previous object*/
  88.  
  89. if(WinCreateObject("WPProgram", title,
  90.    settings,
  91.    "<WP_NOWHERE>",CO_REPLACEIFEXISTS ) == NULLHANDLE)
  92.     printf("Error Creating the Dos VDM Object\n") ;
  93.  
  94.  
  95. /*Terminate PM connection*/
  96. WinDestroyMsgQueue(hmq) ;
  97. WinTerminate(hab) ;
  98.  
  99. return 0 ;
  100. }
  101.  
  102.