***************************** DESCRIPTION This component let you access to Windows95/98/NT structures containing virtually any information provided by the system about installed printers and their pending jobs. Structures available are: PRINTER_INFO_1, 2, 3, 4 and 5, DEVMODE, JOBS_INFO_1 and 2 (see Win32 online help for details), plus some obvious properties (installed printer names list, selected printer name and index in the list and so on), methods and events. Methods allow you pause, resume or clear the whole printer pending work or any single job, and configure printers, printer port and printer network connection (if any). The OnJobStatusChange event is triggered any time the status of any of the pending job changes, due to user action or operating system activity. TAKE CARE OF THE FACT THAT THE SUPPLIED PRINTER INFORMATION IS DRIVER DIPENDENT, that is, some printer drivers give you much more complete pieces of information than others. So you may find empty values, dipending on which printer is currently selected. The jobs stuff seems to work fine, instead, with every printer. I will try to do something better with the component when I'll have the time. In the meantime, I hope it may prove useful to someone. ***************************** DETAILS ----------- MPrinterInfo: a Delphi 3/4 component to get informations about installed printers and to control several printer behaviour (pause - resume etc. on whole printer activity and on single jobs. OS: W95/98/NT. Version: 1.1 Please note that some functions's name have been changed: GetJobsInfo1(Index: Integer) -> JobInfo1(Index: Integer); GetJobsInfo2(Index: Integer) -> JobInfo2(Index: Integer); GetJobStatusDesc(Index: Integer) -> JobStatusDesc(Index: Integer); PROPERTIES: PRINTERLIST: TStringList; the list of "fiendly" names of installed printers (i.e., "Fujitsu DL 3600" and so on); PRINTERCOUNT: Integer; the number of installed printers; PRINTERNAME: String; the "friendly" name of currently selected printer; you may set this value to select a printer from PrinterList by name; PRINTERINDEX: Byte; the zero-based index of currently selected printer in the PrinterList; you may set this value to select a printer from PrinterList by number; function PRINTERINFO1: TPrinterInfo1; function PRINTERINFO2: TPrinterInfo2; function PRINTERINFO3: TPrinterInfo3; WinNT ONLY! In other OS you get a totally empty structure. function PRINTERINFO4: TPrinterInfo4; WinNT ONLY! In other OS you get a totally empty structure. function PRINTERINFO5: TPrinterInfo5; function DEVMODE: TDevMode; You should include the unit "WinSpool" in your unit "uses" clause to get the ability to declare record structures such as "TDevMode" and so on; See Win32 online help for details; The above structures are obviously referred to currently selected printer; function WinNT: Boolean; This function will return True if the target system is running under NT, False otherwise. Take care of the fact that PRINTER_INFO_3 and 4 will be totally empty in OS different from NT. function PRINTERSTATUSDESC: string; the description of printer status, based on the value of the Printer Status as supplied by the system. This piece of information is driver dependent (see above). JOBCOUNT: Integer; the number of pending jobs; function JOBINFO1(Index: Integer): TJobInfo1; function JOBINFO2(Index: Integer): TJobInfo2; these functions will give you, respectively, the JOBS_INFO_1 and JOBS_INFO_2 structures of Windows95/98/NT, referred to the zero-based index of selected job in the list of pending jobs; the Delphi declaration of the record structures is in the file "WinSpool" supplied with Delphi (declare this unit in the "uses" clause of your unit); description in Win32 online help; function JOBSTATUSDESC(Index: Integer): string; a descriptive reporting of current job status (i. e. "-printing -paused"), referred to the zero-based index of selected job in the list of pending jobs; ----------- METHODS REFRESHPRINTERS: forces the re-reading of the list of installed printers (PrinterList, see above). PRINTERPROPERTYDIALOG: Boolean; CONFIGUREPORTDIALOG: Boolean; NETPRINTERCONNECTDIALOG: Boolean; Self-explanatory dialogs to pop up; The result value is false if the function fails; PAUSEPRINTER; RESUMEPRINTER; CLEARPRINTER; Pause, Resume, Clear all pending jobs for the selected printer; PAUSEJOB(Index: Integer); RESUMEJOB(Index: Integer); RESTARTJOB(Index: Integer); DELETEJOB(Index: Integer); Pause, Resume Restart or Delete the single job, identified by it's index in the queue. To get the index of job of interest, you can iterate through the jobs, and get the information you need about the job from JobInfo1 or 2. For example: procedure TForm1.Button1Click(Sender: TObject); var i: integer; begin with MPrinterInfo1 do begin for i := 0 to JobCount - 1 do begin if JobInfo1(i).pDocument = 'MyDocument' then begin PauseJob(i); Break; end; end; end; end; or something like this. ----------- EVENTS ONNOPRINTER (no printer is installed, triggered at startup) This event will help you to take decisions such as disabling buttons or warning the user. Lately, you may test the PrinterCount value to learn about the installed printers number. ONCHANGEPRINTER (user has selected another printer - do this with this component); ONPRINTERSTATUSCHANGE (status of printer has changed); ONJOBSTATUSCHANGE (status of any single job has changed); ***************************** INSTALLATION Just open the .dpk file (menu: file/open) and compile it. You will find the component in the "System" tab, then you may move it where you want. Try to run supplied demo while printing several documents to see the component at work! ***************************** CONTACT ME I will appreciate any comment, suggestion, bug report, or simply helloes. Well, I know it's not perfect. It's freeware! My E-Mail: marcomutti@numerica.it If you should ever need the component source, I will send it to you for only US$ 15.00! This will give you the right to get future improvements (if any). ***************************** DISCLAIMER THIS SOFTWARE AND THE ACCOMPANYING FILES ARE PROVIDED "AS IS" AND WITHOUT ANY WARRANTIES OF ANY KIND, WHETHER EXPRESSED OR IMPLIED! USE AT YOUR ON RISK!