简体   繁体   English

如何使用C ++ Win32 API获取当前的系统域IP地址?

[英]How to Get current system Domain IP Address using C++ Win32 API?

i tried to get current system domain ip address using c++ win32 API. 我试图使用c ++ win32 API获取当前的系统域ip地址。

How Can i Achieve this? 我怎样才能做到这一点?

If you mean a way to get your public ip behind a NAT, you have to open a socket, bind it and connect to a server and request it to answer you what your ip is. 如果您想让公共IP位于NAT之后,则必须打开一个套接字,将其绑定并连接到服务器,然后请求它回答您的IP。 not an easy task. 绝非易事。 If you only want to know your private ip, you can read this thread on stackoverflow : Get the IP Address of local computer 如果只想知道您的私有IP,则可以在stackoverflow上阅读此线程: 获取本地计算机的IP地址

如果您是指本地系统的DNS服务器的IP地址,则可以执行ipconfig /all并解析其输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM