Solved

Setting a printer to Pause

Posted on 1998-09-19
6
429 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now