abasov
Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору Victor_Dobrov Планируете сделать проверку доступности сети? Может Ping по первому TTL, достаточно будет. Если нет, возможно есть пример? Есть код Delphi, помогите перекроить в iss Код: //Implementing Internet Pings Using Icmp.dll Unit ping; Interface Uses Windows, SysUtils, Classes; Type TSunB = Packed Record s_b1, s_b2, s_b3, s_b4: byte; End; TSunW = Packed Record s_w1, s_w2: word; End; PIPAddr = ^TIPAddr; TIPAddr = Record Case integer Of 0: (S_un_b: TSunB); 1: (S_un_w: TSunW); 2: (S_addr: longword); End; IPAddr = TIPAddr; Function IcmpCreateFile: THandle; stdcall; external 'icmp.dll'; Function IcmpCloseHandle(icmpHandle: THandle): boolean; stdcall; external 'icmp.dll' Function IcmpSendEcho(IcmpHandle: THandle; DestinationAddress: IPAddr; RequestData: Pointer; RequestSize: Smallint; RequestOptions: pointer; ReplyBuffer: Pointer; ReplySize: DWORD; Timeout: DWORD): DWORD; stdcall; external 'icmp.dll'; Function PingAd(InetAddress: String): boolean; Implementation Uses WinSock; Function Fetch(Var AInput: String; Const ADelim: String = ' '; Const ADelete: Boolean = true) : String; Var iPos: Integer; Begin If ADelim = #0 Then Begin // AnsiPos does not work with #0 iPos := Pos(ADelim, AInput); End Else Begin iPos := Pos(ADelim, AInput); End; If iPos = 0 Then Begin Result := AInput; If ADelete Then Begin AInput := ''; End; End Else Begin result := Copy(AInput, 1, iPos - 1); If ADelete Then Begin Delete(AInput, 1, iPos + Length(ADelim) - 1); End; End; End; Procedure TranslateStringToTInAddr(AIP: String; Var AInAddr); Var phe: PHostEnt; pac: PChar; GInitData: TWSAData; Begin WSAStartup($101, GInitData); Try phe := GetHostByName(PChar(AIP)); If Assigned(phe) Then Begin pac := phe^.h_addr_list^; If Assigned(pac) Then Begin With TIPAddr(AInAddr).S_un_b Do Begin s_b1 := Byte(pac[0]); s_b2 := Byte(pac[1]); s_b3 := Byte(pac[2]); s_b4 := Byte(pac[3]); End; End Else Begin Raise Exception.Create('Error getting IP from HostName'); End; End Else Begin Raise Exception.Create('Error getting HostName'); End; Except FillChar(AInAddr, SizeOf(AInAddr), #0); End; WSACleanup; End; Function PingAd(InetAddress: String): boolean; Var Handle: THandle; InAddr: IPAddr; DW: DWORD; rep: Array[1..128] Of byte; Begin result := false; Handle := IcmpCreateFile; If Handle = INVALID_HANDLE_VALUE Then Exit; TranslateStringToTInAddr(InetAddress, InAddr); DW := IcmpSendEcho(Handle, InAddr, Nil, 0, Nil, @rep, 128, 0); Result := (DW <> 0); IcmpCloseHandle(Handle); End; End. |
| Всего записей: 345 | Зарегистр. 12-11-2002 | Отправлено: 17:56 31-07-2008 | Исправлено: abasov, 19:22 31-07-2008 |
|