Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Setting a printer to Pause

Posted on 1998-09-19
6
Medium Priority
?
450 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 400 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

916 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