Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Setting a printer to Pause

Posted on 1998-09-19
6
434 Views
Last Modified: 2010-04-03
How can I set a printer to pause and restart it. I think it is with TPrinter.SetPrinter. A example of code would be great.
0
Comment
Question by:ymailhot
  • 3
  • 2
6 Comments
 

Author Comment

by:ymailhot
ID: 1340280
Edited text of question
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1340281
How about this.???

uses Printers;
{...}

Printer.BeginDoc;
//Do some stuff...If button is pressed then...stop

Printer.EndDoc;
//Then again...BeginDoc;

Is this gonna work>?
0
 

Author Comment

by:ymailhot
ID: 1340282
I am talking about pausing the printer. The job is already spooled to the print manager.
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 5

Expert Comment

by:ronit051397
ID: 1340283
0
 

Author Comment

by:ymailhot
ID: 1340284
Thank you ronit. This proved to be very helpful. You may have the points.
0
 
LVL 5

Accepted Solution

by:
ronit051397 earned 100 total points
ID: 1340285
OK. Just for the others to see:

"...
Hello mates !

              Well.. at last I did it ! Let me explain !

              Well, a couple of days ago I needed a code to stop de Printer at Window NT..
              so I grab the WINAPI help file and tried to find how to do it.. After lot of
              tries nothing worked.. so I had a look at this newsgroup.. I saw that many
              people had the same problems with the SetPrinter call as me.. I mean or
              Address errors or not working... so my problem was not solved.. BUT.. what
              hapenned.. I don't know how I saw the last part of the OpenPrinter statement
              at the help file and saw that if somebody wanted to do anything altering the
              printer it has to be opened with PRINTER_ALL_ACCESS parameter at the
              PrinterDefaults struct... aha !!!... after that all worked fine... just try
              out my source.. you will see...

              I wish this code would be helpfull to anyone !

              Albert

              procedure whatever
              var
               hPrinter : THandle;
               PrinterName : PChar;
               PrinterDefaults : TPrinterDefaultsA;
               DevMode : PDeviceModeA;
               Needed : integer;
              begin
               PrinterName := PChar(Printer.Printers[Printer.PrinterIndex]);

               WinSpool.OpenPrinter(PrinterName,hPrinter,nil);

               Needed :=
              WinSpool.DocumentProperties(Handle,hPrinter,PrinterName,DevMode^,DevMode^,0)
              ;
               if Needed < 0 then
                begin
                 exit;
                end;

               GetMem(DevMode,Needed);
              WinSpool.DocumentProperties(Handle,hPrinter,PrinterName,DevMode^,DevMode^,DM
              _COPY);

               PrinterDefaults.pDatatype := nil;
               PrinterDefaults.pDevMode := @DevMode^;
               PrinterDefaults.DesiredAccess := PRINTER_ALL_ACCESS;

               ClosePrinter(hPrinter);

               if OpenPrinter(PrinterName,hPrinter,@PrinterDefaults) then
                begin
                 if WinSpool.SetPrinter(hPrinter,0,nil,PRINTER_CONTROL_PAUSE) then
                  begin
                   ClosePrinter(hPrinter);
                  end
                end;

               ClosePrinter(hPrinter);
               FreeMem(DevMode);
              end;
."

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 81
Dev Express grid collapse 2 45
tidtcpserver connection lost handle 2 100
Firemonkey DbLookupComboBox equivalent ? 2 53
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question