Im not sure if this is meant to be in the networking section, if so, sorry.
It uses the win api and its more of a windows question in general anyway.
Im trying to find out the status of all computers connected on my LAN, i want to find out if they are online/offline and if online, i want to find out if they are logged in (if possible).
So far, i managed to find some code that lists all computer names on a network, and using this list, i used somewhat of a hack to check if they were online/offline (pinging them and hiding the command prompt).
but the problem is, this code takes about 100 ms per computer, and i got around 30 computers on my LAN.. if im lucky, it takes 3 seconds, but usually, it takes anywhere between 1 to 10 minutes.. also, its not that accurate, sometimes it returns offline for a computer thats definately online.Code:void NetworkStatus() { //vars do { pbuf = NULL; statusNetAPI = NetServerEnum(NULL, 101, &pbuf, 25600, &entriesread, &totalentries, SV_TYPE_ALL, NULL, &resume); if ((statusNetAPI == NERR_Success || statusNetAPI == ERROR_MORE_DATA) && pbuf != NULL) { pSI = (SERVER_INFO_101 *)pbuf; for (i = 0; i < entriesread; ++i) { sprintf(sBuffer, "%S: ", pSI[i].sv101_name); strcat(sReturn, sBuffer); sprintf(sBuffer, "ping %S -n 1 -w 100", nBegin); nStart = GetTickCount(); LoadProgram(sBuffer); //just loads 'sBuffer' and hides the window (async) if (GetTickCount() - nStart >= 50) //Offline else //Online } } if (pbuf != NULL) NetApiBufferFree(pbuf); } while (statusNetAPI == ERROR_MORE_DATA); }



LinkBack URL
About LinkBacks


