Get the host name and IP address of the computer

zhaozj2021-02-11  215

Get the host name and IP address of the computer

Author: editor: China Network Technology compiler: Liu Feng environment: Visual C 5 SP1 / 2 WINDOW NT4 or WINDOWS 95. Demand: #include Link Library: Wsock32.lib detailed code: {WORD wVersionRequested; WSADATA wsaData; Char name [255]; cstring ip; phostent hostinfo; wversionRequested = makeword (2, 0); if (WSAStartup (WSASTARTUP (WSASTARTASTED, & WSADATA) == 0) {IF (getHostName (name, sizeof (name)) == 0) { IF ((Hostinfo = gethostByname (Name))! = null) {ip = inet_ntoa (* (struct in_addr *) * Hostinfo-> h_addr_list);}} wsacleanup ();}}

转载请注明原文地址:https://www.9cbs.com/read-5737.html

New Post(0)