如何使用Win32 API在给定端口名称的情况下获取网络打印机的IP地址? [英] How can I get the IP address of a network printer given the port name using the Win32 API?

查看:75
本文介绍了如何使用Win32 API在给定端口名称的情况下获取网络打印机的IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在给定端口名称的情况下,如何获取网络打印机的IP地址,使用win32 API?

How can I get the IP address of a network printer given the port name, using win32 API?

我尝试查看 PRINTER_INFO_ *结构,但似乎那里不存在.

I tried looking into the PRINTER_INFO_* structs, but it seems it is not present there.

推荐答案

我不认为有一种获取IP地址的标准方法.网络端口监视器可能有不同的不兼容实现.对于我的网络打印机,IP地址是端口名称的一部分(例如, IP_192_168.1.104 ).如果是这种形式,那么您也许可以解析出来,但是我不认为这是普遍的.

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.

使用 EnumPorts 可以确定它是否是网络打印机,但是我仍然看不到获取IP地址的方法.

Using EnumPorts you can determine if it's a network printer, but I still don't see a way to get the IP address.

这篇关于如何使用Win32 API在给定端口名称的情况下获取网络打印机的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆