How to scan all IPs and usernames in network neighbors
#include "winsock2.h" #include "afxtempl.h" #include "winnetwk.h"
Join the lib link Project- "Setting-" LINK- "Object / Libary Modules Add to WS2_32.lib mpr.lib
Clist
CSTRING STRTEMP; STRUCT HOSTENT * HOST; STRUCT IN_ADDR * PTR; / / Get IP Address
DWORD DWSCOPE = Resource_Context; NetResource * NetResource = NULL; Handle Henum; WnetopENENUM (DWScope, Null, Null, Null, & Henum);
WSADATA WSADATA; / / Start enumerating network resources WSAStartup (Makeword (1, 1), & WSADATA);
if (hEnum) // If the handle is valid {DWORD Count = 0xFFFFFFFF; DWORD BufferSize = 2048; LPVOID Buffer = new char [2048]; WNetEnumResource further enumeration call work WNetEnumResource (hEnum // Call WSAStartup, & Count, Buffer, & Buffersize); NetResource = (NetResource *) BUFFER;
Char szhostname [200];
for (unsigned int i = 0; i
// Uninstall Winsock.dll wsacleanup ();
List this machine IP address and name cstring m_stripaddress; wsadata wsadata; int ret = wsastartup (MakeWord (0x02, 0x02), & wsadata); if (IRET! = 0) {trace ("Initializing Winsock Dynamic Library error!"); M_StripAddress = ""; Return;
Struct in_addr localaddr; struct hostent * hp = null; char hostname [50]; gethostname (Hostname, 49); // host name
HP = gethostByname (hostname); // host information Memcpy (& localaddr, hp-> h_addr, hp-> h_length); // address