阅读:766回复:2
以前从没有网络编程,谁能帮我写一个函数?(重谢,太急了)
输入一个IP地址,返回看是否可以ping通!
vc 代码 |
|
|
沙发#
发布于:2004-04-20 10:06
#include <iphlpapi.h>
//----------------------------------------------------------------- void CNewPingDlg::OnPingbutton() { int rc; IPAddr ia; UpdateData(TRUE); ia = inet_addr (m_ip_address); rc = NewPing(ia, (ULONG*)&m_hops_count,(ULONG*)&m_rtt); if (rc == 0) m_status = \"Get RTTL and Hops Succeeded\"; else m_status.Format(\"Host not responding or no route, rc = %d\",rc); UpdateData(FALSE); MessageBeep(1000); return; } //------------------------------------------------------------- int NewPing(IPAddr ia, ULONG *hops_count, ULONG *rtt) { boolean IsOk; IsOk = GetRTTAndHopCount(ia, hops_count,128, rtt); //the iphlpapi call if (IsOk == TRUE) return 0; return GetLastError(); } //--------------------------------------------------------------- 老虎,你自己试一下 :D |
|
|
板凳#
发布于:2004-04-20 11:30
thanks!
|
|
|