Take details of the printer installed by Winspool

zhaozj2021-02-08  237

Take details of the printer installed by Winspool

Testing the form of the form "fprint" in the Delphi 6 Professional Version on Windows 2000 Professional Version On Windows 2000 Professional Version ON Windows 2000, there is two controls of TMEMO and TCOMBOBOX

Unit unit1;

Interface

Uses Windows, Messages, Sysutils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Stdctrls, ExtCtrls, Comctrls, Tabedit, Printers, Buttons, Winspool

type TPrinterInfo = record SeverName: PChar; PrinterName: PChar; ShareName: PChar; PortName: PChar; DriverName: PChar; Comment: PChar; Location: PChar; DeviceMode: PDeviceModeA; SepFile: PChar; PrintProcessor: PChar; DataType: PChar; Parameters: A d; ;;;; ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

TFPrint = class (TForm) Memo1: TMemo; ComboBox1: TComboBox; procedure FormShow (Sender: TObject); procedure ComboBox1Change (Sender: TObject); private {Private declarations} public {Public declarations} end;

Function getCurrentPrinterInformation: tprinterinfo; function getcurrentprinterHandle: thandle;

VAR fprint: tfprint;

IMPLEMENTATION

{$ R * .dfm}

function GetCurrentPrinterHandle: THandle; var Device, Driver, Port: array [0..255] of char; hDeviceMode: THandle; begin Printer.GetPrinter (Device, Driver, Port, hDeviceMode); if not OpenPrinter (@Device, Result, nil Then RaiselasTwin32error;

function GetCurrentPrinterInformation: TPrinterInfo; var hPrinter: THandle; pInfo: PPrinterInfo2; bytesNeeded: DWORD; begin hprinter: = GetCurrentPrinterHandle; try Winspool.GetPrinter (hPrinter, 2, Nil, 0, @bytesNeeded); pInfo: = AllocMem (bytesNeeded); try Winspool.GetPrinter (hPrinter, 2, pInfo, bytesNeeded, @bytesNeeded); Result.SeverName: = pInfo ^ .pServerName; Result.PrinterName: = pInfo ^ .pPrinterName; Result.ShareName: = pInfo ^ .pShareName; Result.PortName: = pInfo ^ .pPortName; Result.DriverName: = pInfo ^ .pDriverName; Result.Comment: = pInfo ^ .pComment; Result.Location: = pInfo ^ .pLocation; Result.DeviceMode: = pInfo ^ .pDevMode; Result.SepFile: = Pinfo ^ .psepfile; Result.PrintProcessor: = Pinfo ^ .pprintprocessor; Result.DataType: = Pinfo ^ .pdattype; Result.Parameters : = PInfo ^ .pParameters; Result.SecurityDescriptor: = pInfo ^ .pSecurityDescriptor; Result.Attributes: = pInfo ^ .Attributes; Result.DefaultPriority: = pInfo ^ .DefaultPriority; Result.StartTime: = pInfo ^ .StartTime; Result.UntilTime : = pInfo ^ .UntilTime; Result.Status: = pInfo ^ .Status; Result.Jobs: = pInfo ^ .cJobs; Result.AveragePPM: = pInfo ^ .AveragePPM; finally FreeMem (pInfo); end; finally ClosePrinter (hPrinter) ;

procedure TFPrint.FormShow (Sender: TObject); begin ComboBox1.Items.Assign (Printer.Printers); ComboBox1.ItemIndex: = 0; ComboBox1.OnChange (nil); end; procedure TFPrint.ComboBox1Change (Sender: TObject); var PrinterInfo : TPrinterInfo; begin PrinterInfo: = GetCurrentPrinterInformation; memo1.Clear; with memo1.Lines do begin Add ( 'GENERAL INFORMATION'); Add ( ''); Add ( 'ServerName:' PrinterInfo.SeverName); Add ( 'PrinterName: ' PrinterInfo.PrinterName); Add (' ShareName: ' PrinterInfo.ShareName); Add (' PortName: ' PrinterInfo.PortName); Add (' DriverName: ' PrinterInfo.DriverName); Add (' Comment: ' PrinterInfo.Comment); Add ( 'Location:' PrinterInfo.Location); Add ( 'SepFile:' PrinterInfo.SepFile); Add ( 'PrintProcessor:' PrinterInfo.PrintProcessor); Add ( 'DataType:' PrinterInfo. DataType); Add ('parameters:' printerinfo.Parameters); Add ('Attributes:' INTOSTR (PrinterInfo.attributes); add ('defaultpriority: ' IntToStr (PrinterInfo.DefaultPriority)); Add (' StartTime: ' IntToStr (PrinterInfo.StartTime)); Add (' UntilTime: ' IntToStr (PrinterInfo.UntilTime)); Add (' Status: ' IntToStr (PrinterInfo .Status); add ('Jobs:' INTOSTR (PrinterInfo.Jobs); add ('averageppm:' INTOSTR (PrinterInfo.aveRageppm); add (''); add ('devicemode information "; add ('');

Add ( 'DeviceName:' PrinterInfo.DeviceMode.dmDeviceName); Add ( 'SpecVersion:' IntToStr (PrinterInfo.DeviceMode.dmSpecVersion)); Add ( 'DriverVersion:' IntToStr (PrinterInfo.DeviceMode.dmDriverVersion)); Add ( 'Size:' IntToStr (PrinterInfo.DeviceMode.dmSize)); Add ( 'DriverExtra:' IntToStr (PrinterInfo.DeviceMode.dmDriverExtra)); Add ( 'Fields:' IntToStr (PrinterInfo.DeviceMode.dmFields)); Add ( 'Orientation:' IntToStr (PrinterInfo.DeviceMode.dmOrientation)); Add ( 'PaperSize:' IntToStr (PrinterInfo.DeviceMode.dmPaperSize)); Add ( 'PaperLength:' IntToStr (PrinterInfo.DeviceMode.dmPaperLength)); Add ( 'paperWidth:' IntToStr (PrinterInfo.DeviceMode.dmPaperWidth)); Add ( 'Scale:' IntToStr (PrinterInfo.DeviceMode.dmScale)); Add ( 'Copies:' IntToStr (PrinterInfo.DeviceMode.dmCopies)) Add ('defaultsource:' INTOSTR (PrinterInfo.deviceMode.dmdefaultsource); add ('printquality:' INTOSTR (PrinterInfo.deviceMode.dmPrintQuality); add ( 'Color:' IntToStr (PrinterInfo.DeviceMode.dmColor)); Add ( 'Duplex:' IntToStr (PrinterInfo.DeviceMode.dmDuplex)); Add ( 'YResolution:' IntToStr (PrinterInfo.DeviceMode.dmYResolution)); Add ( 'TTOption:' IntToStr (PrinterInfo.DeviceMode.dmTTOption)); Add ( 'Collate:' IntToStr (PrinterInfo.DeviceMode.dmCollate)); Add ( 'LogPixels:' IntToStr (PrinterInfo.DeviceMode.dmLogPixels)); Add ('Bitsperpel:' INTOSTR (PrinterInfo.deviceMode.dmbitsperpel); Add ('

PelsWidth: ' IntToStr (PrinterInfo.DeviceMode.dmPelsWidth)); Add (' PelsHeight: ' IntToStr (PrinterInfo.DeviceMode.dmPelsHeight)); Add (' DisplayFlags: ' IntToStr (PrinterInfo.DeviceMode.dmDisplayFlags)); Add ( 'DisplayFrequency:' IntToStr (PrinterInfo.DeviceMode.dmDisplayFrequency)); Add ( 'ICMMethod:' IntToStr (PrinterInfo.DeviceMode.dmICMMethod)); Add ( 'ICMintent:' IntToStr (PrinterInfo.DeviceMode.dmICMIntent)); Add ( 'MediaType:' IntToStr (PrinterInfo.DeviceMode.dmMediaType)); Add ( 'DitherType:' IntToStr (PrinterInfo.DeviceMode.dmDitherType)); Add ( 'ICCManufacturer:' IntToStr (PrinterInfo.DeviceMode.dmICCManufacturer)); Add ( 'ICCModel:' IntToStr (PrinterInfo.DeviceMode.dmICCModel)); Add ( 'PanningWidth:' IntToStr (PrinterInfo.DeviceMode.dmPanningWidth)); Add ( 'PanningHeight:' IntToStr (PrinterInfo.DeviceMode.dmPanningHeight)) ; End; end; end .// Rock // Reprinted please keep this information

转载请注明原文地址:https://www.9cbs.com/read-2783.html

New Post(0)