C++ Windows function call that get local hostname and IP address

前端 未结 2 1874
悲哀的现实
悲哀的现实 2020-12-16 03:01

Is there built-in windows C++ function call that can get hostname and IP address? Thanks.

2条回答
  •  庸人自扰
    2020-12-16 04:07

    To get the hostname you can use: gethostname or the async method WSAAsyncGetHostByName

    To get the address info, you can use: getaddrinfo or the unicode version GetAddrInfoW

    You can get more information about the computer name like the domain by using the Win32 API: GetComputerNameEx.

提交回复
热议问题