home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- * LOAD *
- * ------------------------------------------------------------------------ *
- * Purpose: Loads an OS/2 program as a presentation manager icon. *
- * ------------------------------------------------------------------------ *
- * Type: External command, used in the OS/2 session only. *
- * ------------------------------------------------------------------------ *
- * Syntax: LOAD "session title" /FS|/WIN|/PM [/I] [/ICON=iconName] *
- * command [options] *
- * ------------------------------------------------------------------------ *
- * Parameters: session title *
- * This variable specifies the title of the new session as it *
- * will appear in the Task Manager. The session title may be *
- * up to 31 characters long and must be surrounded by *
- * quotation marks. *
- * *
- * /FS *
- * This parameter tells MS OS/2 that the application is *
- * not window compatible and must be run in a full-screen *
- * session. *
- * *
- * /WIN *
- * This parameter tells MS OS/2 that the application is to be *
- * run in a presentation manager window. *
- * *
- * /PM *
- * This parameter tells MS OS/2 that the application is a *
- * Presentation Manager application. *
- * *
- * /I *
- * This parameter causes the program being loaded to inherit *
- * the environment set in the CONFIG.SYS file. *
- * *
- * /ICON=iconName *
- * This parameter is used to specify the path and file name *
- * of the icon file associated with the application. *
- * If the icon file is not in the current directory, the *
- * full pathname of the icon file is required. *
- * *
- * command *
- * This variable specifies the name and extension of the *
- * program to be loaded. *
- * *
- * options *
- * This variable specifies any command line arguments that *
- * are to be passed to the program being loaded. *
- * ------------------------------------------------------------------------ *
- * Program written by: Rick Yoder *
- * CIS 73457,521 *
- ****************************************************************************/
-
- #define INCL_DOSSESMGR
- #include <os2.h>
- #include <stdio.h>
- #include <string.h>
- #include <malloc.h>
- #include <qfn.h>
-
- /****************************************************************************/
- void main( int argc, char *argv[] )
- {
- static char *msg = "Usage: LOAD \"session title\" /FS|/WIN|/PM [/I] [/ICON=iconName]\n command [options]\n";
-
- STARTDATA stdata;
- USHORT idSession,pid;
- USHORT code;
-
- char *options;
- int n,m,len;
-
-
- /* Check for illegal number of command line arguments */
- if ( argc < 4 )
- {
- printf( msg );
- return;
- }
-
- /* Get session title */
- if ( strlen(argv[1]) > 31 )
- {
- printf( "ERROR: Session title too long (max = 31 chars).\n" );
- return;
- }
- stdata.PgmTitle = argv[1];
-
- /* Get session type */
- /* Note: stdata.SessionType cannot be 0 due to the fact that
- * a general protection fault may occur if the program
- * being loaded is a presentation manager program.
- */
- if ( 0 == stricmp(argv[2],"/FS") ) stdata.SessionType = 1;
- else if ( 0 == stricmp(argv[2],"/WIN") ) stdata.SessionType = 2;
- else if ( 0 == stricmp(argv[2],"/PM") ) stdata.SessionType = 3;
- else { printf(msg); return; }
-
- /* Get inheritance method */
- if ( 0 == stricmp(argv[3],"/I") )
- {
- stdata.InheritOpt = 0; // Get environment from CONFIG.SYS
- n = 4;
- }
- else
- {
- stdata.InheritOpt = 1; // Inherit environment from LOAD process
- n = 3;
- }
-
- /* Get icon file name */
- if ( 0 == strnicmp(argv[n],"/ICON=",6) )
- {
- stdata.IconFile = qfn(&argv[n][6]);
- if ( stdata.IconFile == NULL )
- {
- printf( "ERROR: Illegal drive or dir in icon filename\n" );
- return;
- }
- n++;
- }
- else
- stdata.IconFile = NULL;
-
- /* Get program file name */
- stdata.PgmName = argv[n++];
-
- /* Get program arguments */
- for ( m = n,len = 0; m < argc; m++ ) len += strlen(argv[n]);
- if ( NULL == (options = calloc(len+1,sizeof(char))) )
- {
- printf( "ERROR: Insufficient memory\n" );
- return;
- }
- for ( ; n < argc; n++ ) strcat( options,argv[n] );
- stdata.PgmInputs = options;
-
- /* Fill in remaining fields in STARTDATA structure */
- stdata.Length = 50; // length of structure
- stdata.Related = FALSE; // start new independent session
- stdata.FgBg = TRUE; // start new session in background
- stdata.TraceOpt = 0; // program not being traced
- stdata.TermQ = NULL; // not used
- stdata.Environment = NULL; // not used
- stdata.PgmHandle = NULL; // don't know what this parm. does
- stdata.PgmControl = 4; // start session as PM icon
- stdata.InitXPos = 0; // position values not used,
- stdata.InitYPos = 0; // initialized to zero.
- stdata.InitXSize = 0;
- stdata.InitYSize = 0;
-
- /* Start new program */
- code = DosStartSession( &stdata,&idSession,&pid );
- if ( code != 0 ) printf( "Error %#04x while starting session \"%s\"\n",
- code,argv[1] );
-
- return;
- }
- /****************************************************************************/
-