home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega CD-ROM 1
/
megacd_rom_1.zip
/
megacd_rom_1
/
DESQVIEW
/
DVLOAD.ZIP
/
DVLOAD.C
next >
Wrap
Text File
|
1988-04-22
|
4KB
|
179 lines
/* dvload.c
by Rod Murillo 303-761-0410 murillo@boulder.colorado.edu
Start a new task in Desqview from the DOS command line.
NOTE: You must have the C API Library to compile this. The
large memory model is recomended. If you are new to the C library
drop me a line if you get frustrated trying to compile your first
program. I was.
This program was compiled with Turbo C 1.5
*/
#undef DEBUG
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <fcntl.h>
#include <conio.h>
#include <errno.h>
#include <dvapi.h>
/* buffers sizes for storing and reading the PIF */
#define PIFSIZE 416
#define BUFFSIZE 512
/* parameter line flag position and mask in PIF */
#define PARAMFLAG 368 /* flag is at offset 368 */
#define PARAMSET 0x40 /* turn this bit on to flag command line presence */
/* error codes from startapp */
#define NODV 1 /* desqview is not loaded */
#define OPENERR 2 /* error on opening PIF */
#define READERR 3 /* error on reading PIF */
#define STARTERR 4 /* error on starting application */
#define PARAMERR 5 /* error in command line options */
#define MAXERR 5
/* command line argument paramters */
#define COMLINE_START 165 /* PIF buffer position for command lines args */
#define COMLINE_END 228 /* end position for start line */
char pifbuff[BUFFSIZE]; /* PIF buffer */
main(argc,argv)
int argc;
char *argv[];
{
/* function prototypes */
int startapp(char *,int, char *); /* handle PIF reading and app start */
void errmesg(int); /* print error messages */
/* declarations */
char *pifspec = "c:\\dv\\00-pif.dvp";
int errcode;
/* begin */
if (argc < 2 || argc > 3) {
puts("usage: dvl prefix [\"parameters\"]");
exit(PARAMERR);
}
/* load the PIF spec code */
pifspec[6] = argv[1][0];
pifspec[7] = argv[1][1];
errcode = startapp(pifspec,argc,argv[2]);
if (errcode != 0)
errmesg(errcode);
exit(errcode);
} /* end of function main() */
/* startapp() */
int startapp(app,argc,args)
char app[];
int argc;
char args[];
{
int i, j, inhandle;
unsigned long int winhan;
if (api_init() == 0)
return(NODV);
if ((inhandle = open(app, O_RDWR | O_BINARY)) < 0)
return(OPENERR);
if ((read(inhandle, pifbuff, BUFFSIZE)) != PIFSIZE)
return(READERR);
close(inhandle);
if (argc == 3) { /* check for a param string */
/* load the param string into the buffer */
for (i=COMLINE_START; i < COMLINE_END - COMLINE_START + 1; i++)
pifbuff[i] = ' ';
for (i=COMLINE_START, j=0; j < strlen(args) && j < COMLINE_END - COMLINE_START; i++, j++) {
pifbuff[i] = args[j];
}
pifbuff[i] = '\0';
pifbuff[PARAMFLAG] = pifbuff[PARAMFLAG] | PARAMSET; /* flag params on */
}
if (app_start(pifbuff,PIFSIZE) == 0)
return(STARTERR);
else
return(0);
}
/* errmesg() */
void errmesg(code)
int code;
{
char *errorstring;
unsigned long int winhan;
switch (code) {
case NODV: /* desqview is not running */
errorstring = "This program must run under DESQview 2.01 or later.";
break;
case OPENERR: /* error on opening PIF */
errorstring = "Error on opening PIF file.";
break;
case READERR: /* error on reading PIF */
errorstring = "Error on reading PIF file.";
break;
case STARTERR: /* error on starting application */
errorstring = "Error in starting application.";
break;
}
if (code != NODV) {
winhan = win_me();
win_disperor(winhan,errorstring,strlen(errorstring),2,30,0,0);
} else
printf("%s\n",errorstring);
return;
}