I am using VB 6, can any one tell me, how to check whether the LPT1 is connected to a printer?
Actually, I don't install any driver, so that I just put the content to LPT1, but if the LPT1 is not connected to the printer, the program will hang~~~
That's going to be tricky, the physical printer is pretty much ignored by Windows. This is from a MS article:
Under the Windows operating system, a "printer" comprises the printer driver, the print queue, and the input/output path to the physical printer. The operating system treats a physical printer as merely the destination of a print job generated by and passed through a system "Printer," referred to hereafter as a Printer.
The most visible part of a Printer is a print queue. It is managed by the Print Manager or the Printer folders in the Windows 95-style user interfaces. The printer driver is the interface to the Printer that is used by applications to create print jobs via printer Device Contexts. The I/O path for a Printer consists of several layers of system code culminating with a port monitor.
The port monitor is the interface to the physical printer at the down-stream end of a system Printer and is responsible for transferring the data of a print job across whatever connection exists to the physical printer. In the case of bi-directional printers, the port monitor would be responsible for transferring data to and from the physical printer. This connection, and the physical printer, are where errors occur. It is the job of the port monitor to report those errors.
The Spooler does not query for the state of a physical printer to which a Printer is connected. Instead, the state of a physical printer determines the success of a print job at the time it is despooled over the port monitor. If some error occurs in this process, the error is reported by the port monitor and recorded in a print job's status information. The Spooler, in turn, propagates reasonable error information to the Printer Queue.
Consequently, a system Printer reports no status when the Printer queue is empty. In this state, the Printer is assumed ready to accept print jobs. Windows makes this assumption even if the physical printer is in an error state such as off-line. The operating system considers the Printer ready to accept print jobs even if, for some reason, it cannot complete delivery to the physical printer. Such a circumstance is considered an error state in the operating system that must be addressed by the user. It is not considered an error reportable to the application that is allowed to complete the spooling of the print job successfully.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.