var tmpCheckPrinter, tmpSuccess: Boolean; tmpInfo, tmpFilename: String; tmpList, tmpStatusList, tmpFile: TStringList; tmpResult: Byte; tmpStatus: Cardinal; Const ctCheckPrinterConnection = True; ctPrinterIP = '192.168.2.3'; ctPrinterPort = 23; // Telnet Port ctPrinterError = 2; ctOutputPathError = 'C:\Test\In_PDF\Error\'; // Must end with a \ Begin psExitCode := 0; // Default Error psVSE := ''; tmpCheckPrinter := False; tmpInfo := psGetPrinters; psLogWriteStr('Avaibale Printers: ' + tmpInfo); // Send to Telnet Port of Network Printer If ctCheckPrinterConnection Then Begin tmpResult := psSendStrToPrinter('', ctPrinterIP, ctPrinterPort, 5000,0, tmpSuccess); psLogWriteStr('SendStrToPrinter Result: ' + IntToStr(tmpResult)); // Check Result If tmpResult <> 255 Then Begin psLogWriteStr('Printer network connection available; ' + ctPrinterIP); tmpCheckPrinter := True; End Else Begin psVSE := 'SendStrToPrinter Error: ' + IntToStr(tmpResult); psLogWriteStr(psVSE); End; End Else tmpCheckPrinter := True; // Get Printer Information from Spooler If tmpCheckPrinter Then Begin tmpList := psGetPrinterInfo('Dummy Printer', tmpSuccess, tmpInfo); Try If tmpSuccess Then Begin psLogWriteStr('PrinterName: ' + tmpList.Strings[1]); // Index 1 psLogWriteStr('PortName: ' + tmpList.Strings[3]); // Index 3 psLogWriteStr('Status: ' + tmpList.Strings[18]); // Index 18 // Check Result - Def 2 = Error tmpStatus := StrToInt64Def(tmpList.Strings[18], 2); tmpStatusList := psGetPrinterStatusInfo(tmpStatus); Try psVSE := tmpStatusList.CommaText; psLogWriteStr('Print status: ' + psVSE); Finally tmpStatusList.free; End; If (tmpStatus AND ctPrinterError) <> ctPrinterError Then // No Error from Spooler! Begin psLogWriteStr('Do Print, all OK'); psExitCode := 1; End Else psLogWriteStr('Skip Print due to error in status: ' + UIntToStr(tmpStatus)); End Else psLogWriteStr('Get PrintersStatusInfo Error: ' + tmpInfo); Finally tmpList.Free End; End; // Write Error File If psExitCode = 0 Then Begin tmpFile := TStringList.Create; Try tmpFile.Add(psFilePath + psFileName); tmpFile.Add(psVSE); // Printer Status as Text // Save to File tmpFilename := ChangeFileExt(psFileName, '.txt'); Try tmpFile.SaveToFile(ctOutputPathError + tmpFilename); psLogWriteStr('Save to file successful, ' + ctOutputPathError + tmpFilename); Except psLogWriteStr('Save to file exception, ' + ctOutputPathError + tmpFilename); End; Finally tmpFile.Free; End; End; End. (* Printer Info Index: Index 0 = ServerName: PChar; Index 1 = PrinterName: PChar; Index 2 = ShareName: PChar; Index 3 = PortName: PChar; Index 4 = DriverName: PChar; Index 5 = Comment: PChar; Index 6 = Location: PChar; Index 7 = SepFile: PChar; Index 8 = PrintProcessor: PChar; Index 9 = Datatype: PChar; Index 10 = Parameters: PChar; Index 11 = Attributes: Cardinal; Index 12 = Priority: Cardinal; Index 13 = DefaultPriority: Cardinal; Index 14 = StartTime: Cardinal; Index 15 = UntilTime: Cardinal; Index 16 = Status: Cardinal; Index 17 = Jobs: Cardinal; Index 18 = AveragePPM: Cardinal; *)