检测打印机
//是大富翁上看到的,觉得有用
//设计: Linc 2004.04.29
//功能: 判断打印机是否就绪
//参数:允许是网络打印机
function IsPrinterReady: Boolean;
var
hDeviceMode, hGlobal, hPrinter: THandle;
dwNeeded: DWord;
pDefs: TPrinterDefaults;
pInfo: PPrinterInfo2;
bFlag: Boolean;
cDevice,
cDriver,
cPort: array[0..255] of char;
begin
Result := False;
if Printer = nil then Exit;
if Printer.PrinterIndex = -1 then Exit;
hGlobal := 0;
try
Printer.GetPrinter(cDevice, cDriver, cPort, hDeviceMode);
if hDeviceMode = 0 then Exit;
FillChar(pDefs, SizeOf(TPrinterDefaults), 0);
pDefs.DesiredAccess := {STANDARD_RIGHTS_REQUIRED or} PRINTER_ACCESS_USE;
bFlag := OpenPrinter(cDevice, hPrinter, @pDefs);
dwNeeded := GetLastError;
if not bFlag or (hPrinter = INVALID_HANDLE_VALUE) then Exit;
FillChar(pI
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
