Board index » delphi » Determine printer port?

Determine printer port?

How can I determine the port of the current printer, for example LPT1:
or \\mypc\myprinter?
--------
Real address is gerhard.hofm...@planat.de
Delete the nospam
Please copy all answers to my email address

 

Re:Determine printer port?


On Thu, 30 Oct 1997 16:26:56 GMT, gerhard.hofm...@nospam.planat.de

Quote
(Gerhard Hofmann) wrote:
>How can I determine the port of the current printer, for example LPT1:
>or \\mypc\myprinter?

Look at the GetPrinter() function. You can use it like this:

var
        ADevice, ADriver, APort: array [0..255] of Char;
        ADeviceMode: THandle;
Begin
        Printer.GetPrinter (ADevice, ADriver, APort, ADeviceMode);
        ShowMessage(APort);
End;

I Hope this helps.
David Block
dbl...@vdn.com

Re:Determine printer port?


You could use PrinterIndex to get both the current printer name. In usual
connections it should also contains the keyword 'Port' and also the port
name where the printer is connected:

  St:=Printer.Printers[Printer.PrinterIndex];

Then some usual Pascal string manipulating to check if string St contains
substring 'LPT1', 'LPT2'..

Markku Nevalainen

Quote
Gerhard Hofmann wrote:

> How can I determine the port of the current printer, for example LPT1:
> or \\mypc\myprinter?
> --------
> Real address is gerhard.hofm...@planat.de
> Delete the nospam
> Please copy all answers to my email address

Other Threads