comment faire une macro ping d'un champ de texte contenant l'adres

Le
Pschent
comment faire une macro ping d'un champ de texte contenant l'adresse i
Vidéos High-Tech et Jeu Vidéo
Téléchargements
Vos réponses
Gagnez chaque mois un abonnement Premium avec GNT : Inscrivez-vous !
Trier par : date / pertinence
Jacques
Le #6263851
Bonjour,

Und im Klartext ??


"Pschent" news:
comment faire une macro ping d'un champ de texte contenant l'adresse i


Willi2004
Le #6263841
?????????????


"Pschent" news:
comment faire une macro ping d'un champ de texte contenant l'adresse i


Eric
Le #6263831
Bonjour,

En utilisant l'Api ICMPSendEcho (source:http://www.allapi.net/).

A copier dans la partie Déclarations du module du formulaire:

Option Compare Database
Option Explicit

Const SOCKET_ERROR = 0
Private Type WSAdata
wVersion As Integer
wHighVersion As Integer
szDescription(0 To 255) As Byte
szSystemStatus(0 To 128) As Byte
iMaxSockets As Integer
iMaxUdpDg As Integer
lpVendorInfo As Long
End Type
Private Type Hostent
h_name As Long
h_aliases As Long
h_addrtype As Integer
h_length As Integer
h_addr_list As Long
End Type
Private Type IP_OPTION_INFORMATION
TTL As Byte
Tos As Byte
Flags As Byte
OptionsSize As Long
OptionsData As String * 128
End Type
Private Type IP_ECHO_REPLY
Address(0 To 3) As Byte
Status As Long
RoundTripTime As Long
DataSize As Integer
Reserved As Integer
data As Long
Options As IP_OPTION_INFORMATION
End Type
Private Declare Function GetHostByName Lib "wsock32.dll" _
Alias "gethostbyname" (ByVal HostName As String) As Long
Private Declare Function WSAStartup Lib "wsock32.dll" _
(ByVal wVersionRequired&, lpWSAdata As WSAdata) As Long
Private Declare Function WSACleanup Lib "wsock32.dll" () As Long
Private Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" _
(hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
Private Declare Function IcmpCreateFile Lib "icmp.dll" () As Long
Private Declare Function IcmpCloseHandle Lib "icmp.dll" _
(ByVal HANDLE As Long) As Boolean
Private Declare Function IcmpSendEcho Lib "ICMP" _
(ByVal IcmpHandle As Long, ByVal DestAddress As Long, _
ByVal RequestData As String, ByVal RequestSize As Integer, _
RequestOptns As IP_OPTION_INFORMATION, _
ReplyBuffer As IP_ECHO_REPLY, ByVal ReplySize As Long, _
ByVal TimeOut As Long) As Boolean


Puis sur l'évènement clic d'un bouton de commande du formulaire:

Private Sub Commande1_Click()
Dim HostName As String
Dim hFile As Long, lpWSAdata As WSAdata
Dim hHostent As Hostent, AddrList As Long
Dim Address As Long, rIP As String
Dim OptInfo As IP_OPTION_INFORMATION
Dim EchoReply As IP_ECHO_REPLY
Call WSAStartup(&H101, lpWSAdata)
' Affectation de l'adresse à tester
HostName = Me.LeChampContenantAdresseAPinger ' <<<----- A adapter
If GetHostByName(HostName + String(64 - Len(HostName), 0)) _
<> SOCKET_ERROR Then
CopyMemory hHostent.h_name, _
ByVal GetHostByName(HostName _
& String(64 - Len(HostName), 0)), _
Len(hHostent)
CopyMemory AddrList, ByVal hHostent.h_addr_list, 4
CopyMemory Address, ByVal AddrList, 4
End If
hFile = IcmpCreateFile()
If hFile = 0 Then
MsgBox "Unable to Create File Handle"
Exit Sub
End If
OptInfo.TTL = 255
If IcmpSendEcho(hFile, Address, String(32, "A"), 32, _
OptInfo, EchoReply, Len(EchoReply) + 8, 2000) Then
rIP = CStr(EchoReply.Address(0)) & _
"." & CStr(EchoReply.Address(1)) & _
"." & CStr(EchoReply.Address(2)) & _
"." & CStr(EchoReply.Address(3))
Else
rIP = "Timeout ... "
End If
If EchoReply.Status = 0 Then
MsgBox "Reply from " & HostName & " (" & rIP & _
") recieved after " & _
Trim$(CStr(EchoReply.RoundTripTime)) & "ms"
Else
MsgBox rIP & "Failure ..."
End If
Call IcmpCloseHandle(hFile)
Call WSACleanup
End Sub



comment faire une macro ping d'un champ de texte contenant l'adresse i


--
A+
Eric
http://www.mpfa.info/
Archives : http://groups.google.fr/group/microsoft.public.fr.access?hl=fr

Raymond [mvp]
Le #6263811
Bonjour Eric.

Possibilité d'utiliser la même api mais d'une façon plus simple:
http://officesystem.access.free.fr/apiping.htm

--
@+
Raymond Access MVP http://OfficeSystem.Access.free.fr/
Pour débuter sur le forum: http://www.mpfa.info/
Le 26 Avril 2007 à 14h assistez à la web TV et faites avancer la recherche
dans votre entreprise
http://www.comscamp.com/Tracker/Redirect.ashx?linkidDb8ed66-f9f8-456a-bdc8-993dda7415fc


"Eric" %
|
|
|
Publicité
Poster une réponse
Anonyme