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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
EnumPortsyou can determine if it’s a network printer, but I still don’t see a way to get the IP address.