home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
launch1.zip
/
LAUNCH.C
next >
Wrap
C/C++ Source or Header
|
1991-06-08
|
2KB
|
71 lines
#include <os2.h>
#include <stdio.h>
#include <string.h>
#define LENGTH 40
#define FLAG 2
#define ENVS 0L
main(argc,argv)
int argc;
char *argv[];
{
char *ChildName; /*pointer for called name*/
char *LaunchArgs; /*pointer for new args*/
char *CommandLine; /*pointer for new command line*/
char FailBuffer[40]; /*buffer for fail object name*/
char *ptr; /*pointer for character transfer*/
int rc; /*function return code*/
int i,j; /*index for character transfer*/
struct RetInfo ChildID; /*child process ID*/
/*check to see if a command line argument was passed*/
if(argc != 2)
printf("Application name not passed to 'Launch'...program aborted.\n");
/*assign name of called application to ChildName*/
ChildName = argv[1];
/*Prompt user and get new command line parameters*/
printf("Enter command line arguments for %s:\n",ChildName);
gets(CommandLine);
/*Build new set of command line arguments*/
/*Argv[0]*/
ptr=ChildName; /*set ptr to file name*/
for(i=0;i<(strlen(ChildName));i++) /*for length of file name*/
LaunchArgs[i]=*ptr++; /*copy characters*/
LaunchArgs[i++] = '\0'; /*NULL terminate argv[0]*/
/*Argv[1...]*/
ptr=CommandLine; /*reset ptr to command line*/
for(j=0;j<(strlen(CommandLine));j++) /*for length of command line*/
LaunchArgs[i+j]=*ptr++; /*copy characters*/
LaunchArgs[i+j] = '\0'; /*NULL terminate command line*/
/*Call program with new arguments*/
if(rc=DosExecPgm(FailBuffer,LENGTH,FLAG,LaunchArgs,ENVS,&ChildID,ChildName))
{
printf("DosExecPgm error #:%u\n",rc);
printf("Fail Object Buffer contains:%s\n",FailBuffer);
exit(rc);
}
/*Quit and leave child running*/
exit(0);
}