>Does anyone know how to determine the true port of a printer? I am developing under Win2K, and when I issue printer.port, I get a useless "Ne01:" or the like. What I need to know is if the printer is a local printer or a networked printer and if the printer is networked, what port it is connected to. For example, If I am sharing an HP Printer on Box A: I would like to be able to retreive the string: "\\A\HP" The same goes for a local printer: "LPT1:"
>
You can call the Win32 API function WNetGetConnection() to retrieve the UNC of a shared device; if the device name is local, then the return from WNetGetConnection() is null, and the port is the port AFA Windows is concerned.
You can also use ADSI, or the Wscript.Network COM object to return the UNCs of shares at your station.