Solved

Setting a printer to Pause

Posted on 1998-09-19
6
425 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

13 Experts available now in Live!

Get 1:1 Help Now