Get local IP address and username

xiaoxiao2021-03-06  133

Void cgetipdlg :: ONQUERY () {char wshostname [128]; // Storage host name

IF (gethostname (128) == 0) // correct case {m_hostname.setwindowText (wshostname); struct hostent * phost; int client;

Phost = gethostByname (wshostname); // Phost returned to a list of hosts for (Client = 0; phost! = null && phst-> h_addr_list [client]! = null; client ) {lpcstr psz = inet_ntoa (* (Struct) IN_ADDR *) Phost-> h_addr_list [client]); // Get PSZ variable m_ip.addstring (PSZ) pointing to IP;}}}

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

New Post(0)