Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!lll-winken!tekbspa!optilink!cramer From: cramer@optilink.UUCP (Clayton Cramer) Newsgroups: comp.sys.ibm.pc Subject: Re: HELP! Using DOS print Message-ID: <2684@optilink.UUCP> Date: 29 Nov 89 20:24:24 GMT References: <6534@brspyr1.BRS.Com> Distribution: usa Organization: Optilink Corporation, Petaluma, CA Lines: 211 In article <6534@brspyr1.BRS.Com>, jillj@brspyr1.BRS.Com (Jill Jacomine) writes: > I am trying to execute the DOS (version 3.1) print command from within > an executable (compliled using MSC 5.1). The command I am using is: > > spawnvp(P_WAIT,"print.com",args); > > The value of args is "print /D:prn filename". Now, this works well > enough to print the file out, the problem seems to be setting the device > within the program eats up about 200k of memory, and never lets it go. > (I tried setting the device before executing the program, and it seems > to work fine, therefore I am relativly sure the problem is with the > /D:prn option). A chkdsk before running the program shows 655360 bytes > total memory and 594256 bytes free, after execution it is 426720 bytes > total memory and 356616 bytes free. > > I have tried using the SYSTEM function, as well as different SPAWN > functions, but they all yield the same results. Has anyone else come > across this problem, or can anyone offer information as to why this > happens and how it can be corrected. > > Jill Jacomine Yes, it gobbles up memory doing it this way, but I've never seen it grab so much memory, and keep it gobbled. I solved the problem by writing some C to call the BIOS routines. (Thanks to the several people on the net who helped me find a bug). Here's some code that you may find useful, and doesn't require bringing up another copy of DOS, or burning any unnecessary RAM to do print spooling. /*============================================================================ OMSPOOL.C: Print Spooling functions. This module contains print spooling functions for use by OMAPS. Glossary: abbr - abbreviation ============================================================================*/ #include #include #include #define TRUE 1 #define FALSE 0 typedef int bool; typedef struct tSub { char ByteLevel; char* FileName; } tSub; /*===Entries================================================================*/ int SpoolFile(char*); /* add a file to the print queue */ bool SpoolInstall(void); /* install the print spooler */ bool SpoolInstalled(void); /* is the print spooler installed? */ int SpoolRemoveFile(char*); /* remove a spooled file from queue */ int SpoolTerminate(void); /* terminate the spool queue */ int TestDiagT1Admin(void); /* testing & diagnostics T1 */ /*===Functions=============================================================*/ /*==========================================================================*/ /*---------------------------------------------------------------------------- SpoolFile: Add a file to the print queue. Adds a file to the print spool queue. RETURN: int print spool error code (0 = no error) GLOBALS: none ----------------------------------------------------------------------------*/ int SpoolFile(FileName) char* FileName; /* IN: ptr to filename to add to queue */ { union REGS InRegs; union REGS OutRegs; struct SREGS SegRegs; int ErrCode; tSub SubmitFile; tSub* pSubmitFile; pSubmitFile = &SubmitFile; InRegs.x.ax = 0x101; SubmitFile.ByteLevel = 0; SubmitFile.FileName = FileName; InRegs.x.dx = FP_OFF(pSubmitFile); SegRegs.ds = FP_SEG(pSubmitFile); int86x(0x2f, &InRegs, &OutRegs, &SegRegs); if(OutRegs.x.cflag) ErrCode = OutRegs.x.ax; else ErrCode = 0; return(ErrCode); } /*---------------------------------------------------------------------------- SpoolInstall: Install the print spooler. Installs the print spooler. RETURN: bool TRUE: successfully installed FALSE: failed to install GLOBALS: none ----------------------------------------------------------------------------*/ bool SpoolInstall() { return(0 == system("PRINT")); } /*---------------------------------------------------------------------------- SpoolInstalled: Is the print spooler installed? Checks to see if the print spooler is already installed. RETURN: bool TRUE: already installed FALSE: not yet GLOBALS: none ----------------------------------------------------------------------------*/ bool SpoolInstalled() { union REGS InRegs; union REGS OutRegs; struct SREGS SegRegs; int ErrCode; InRegs.x.ax = 0x100; int86x(0x2f, &InRegs, &OutRegs, &SegRegs); return(OutRegs.h.al == 0xff); } /*---------------------------------------------------------------------------- SpoolRemoveFile: Remove a file from the print queue. Removes the specified file from the print spooler queue. RETURN: int print spooler error code GLOBALS: none ----------------------------------------------------------------------------*/ int SpoolRemoveFile(FileName) char* FileName; /* IN: ptr to filename to remove from queue */ { union REGS InRegs; union REGS OutRegs; struct SREGS SegRegs; int ErrCode; InRegs.x.ax = 0x102; InRegs.x.dx = FP_OFF(FileName); SegRegs.ds = FP_SEG(FileName); int86x(0x2f, &InRegs, &OutRegs, &SegRegs); if(OutRegs.x.cflag) ErrCode = OutRegs.x.ax; else ErrCode = 0; return(ErrCode); } /*---------------------------------------------------------------------------- SpoolTerminate: Clear the queue. Removes all current jobs from the print spooler queue. RETURN: int print spooler error code (0 = no error) GLOBALS: none ----------------------------------------------------------------------------*/ int SpoolTerminate() { union REGS InRegs; union REGS OutRegs; struct SREGS SegRegs; int ErrCode; InRegs.x.ax = 0x103; int86x(0x2f, &InRegs, &OutRegs, &SegRegs); if(OutRegs.x.cflag) ErrCode = OutRegs.x.ax; else ErrCode = 0; return(ErrCode); } -- Clayton E. Cramer {pyramid,pixar,tekbspa}!optilink!cramer My definition of social justice: those who refuse to work deserve to go hungry. =============================================================================== Disclaimer? You must be kidding! No company would hold opinions like mine!