How can I get the IP address of a network printer given the port name, using win32 API?
I tried looking into the PRINTER_INFO_* structs
, but it seems it is not present there.
you can get the port name by PRINTER_INFO_2,and the get the ip from the registry,the path is: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports the ip store in "HostName"
I don't think there's a standard way to get the IP address. There are probably different incompatible implementations of network port monitors. For my network printer, the IP address is part of the port name (e.g., IP_192_168.1.104
). If it's of that form, then you might be able to parse it out, but I don't think this is universal.
Using EnumPorts
you can determine if it's a network printer, but I still don't see a way to get the IP address.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With