Article View: borland.public.cppbuilder.nativeapi
Article #6658Re: Error when writing file
From: Bob Gonder
Date: Thu, 21 Apr 2005 20:23
Date: Thu, 21 Apr 2005 20:23
47 lines
2702 bytes
2702 bytes
mike wrote:
>1- I am moving one spool file from a printer to another printer.
Are the printers attached to the same computer?
Maybe you could get away with a simple rename (see below)
>FileBuffer = (char *)( GlobalAlloc( GPTR, 16384 ) );
GPTR is a waste of time as you will be filling the buffer with a read
anyway.
> nErr = ::WritePrinter( hPrinter,(LPVOID)FileBuffer, ReadSize,
>&WrittenSize);
Make sure you check ReadSize before writing.
>5- Once the file has been transferred I release the working buffer as
Why not hang on to it until all the files are transfered?
(Not that it hurts, just a waste of cpu time.)
>Now this seems to work for awhile, that is the transfer of the data works
>for a number of files, and then I get the error indicated
"Not enough storage is available to process this command"
Perhaps the print server has run out of disk/spool space?
Do you cancel and remove the original job files as you go along?
Perhaps it would work better to use AddJob() to get a normal file name
and use normal file copying to place the file on the new printer's
computer. (See the docs for AddJob)
MoveFile() could be faster, especially if it is the same computer.
I don't know if you are allowed to delete a job file, but it would
make life simpler...
SetJob( hp, OldJob, 0,NULL, JOB_CONTROL_PAUSE)
if( MoveFile( OldFile, NewFile ) )
{
SetJob( hp, OldJob, 0,NULL,JOB_CONTROL_CANCEL)
ScheduleJob( NewJob )
}else{
if( CopyFile( OldFile, NewFile, FALSE) )
{ RemoveFile( OldFile );
SetJob( hp, OldJob, 0,NULL,JOB_CONTROL_CANCEL)
ScheduleJob( NewJob )
} }
Technical Details
Message-ID:
<c90g61pa5uesrm6vm6aq16k4l4ipfve8kt@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!solnet.ch!solnet.ch!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<4263fc8e@newsgroups.borland.com> <a4c86151pajfdndsk6mt25u7jr4nh11hnv@4ax.com> <4266745e@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,2bc06fa753d04116 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Error when writing file Date: Thu, 21 Apr 2005 13:23:35 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <c90g61pa5uesrm6vm6aq16k4l4ipfve8kt@4ax.com> References: <4263fc8e@newsgroups.borland.com> <a4c86151pajfdndsk6mt25u7jr4nh11hnv@4ax.com> <4266745e@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 67.77.155.52 X-Trace: newsgroups.borland.com 1114115011 67.77.155.52 (21 Apr 2005 13:23:31 -0800) Lines: 49 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!solnet.ch!solnet.ch!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail