You need to specify the time in the ping being sent, and take the data from the response to check if there is an ip on the network or not. Because low-level API functions (for example, built-in ICMP.DLL) seemed complicated. So far I have decided to stop at IdICMP. Tell me what libraries are needed for IdICMP and can anyone give a link to the article how to work with it (all references). I am writing MS VS C ++ 2008 Express Edition.
In google did not find, msdn for it is not, examples without #include.
#include "stdafx.h" #include "conio.h" #include <iostream>; #include "winsock2.h" #include "windows.h" #include "locale.h" int main() { IdIcmpClient1->ReceiveTimeout=1000; IdIcmpClient1->Host="77.88.21.3"; IdIcmpClient1->Ping(); _getch(); }
Errors produced by the compiler:
.\2.cpp(13) : error C2065: IdIcmpClient1: необъявленный идентификатор .\2.cpp(13) : error C2227: выражение слева от "->ReceiveTimeout" должно указывать на тип класса, структуры или объединения либо на универсальный тип тип: 'unknown-type' .\2.cpp(14) : error C2065: IdIcmpClient1: необъявленный идентификатор .\2.cpp(14) : error C2227: выражение слева от "->Host" должно указывать на тип класса, структуры или объединения либо на универсальный тип тип: 'unknown-type' .\2.cpp(15) : error C2065: IdIcmpClient1: необъявленный идентификатор .\2.cpp(15) : error C2227: выражение слева от "->Ping" должно указывать на тип класса, структуры или объединения либо на универсальный тип тип: 'unknown-type' 2 - ошибок 6, предупреждений 0