L'auteur
Mike Gagnon Canada Membre Simple # 0000000025 enregistré le 14/10/2004
Gagnon Mike Pointe Cla H9R 3K8 de la société Carver Technologies Inc. Fiche personnelle
Note des membres
pas de note
|
Contributions > 09 - Automation > WMI (Windows Management Instrumentation)
PING
# 0000000312
ajouté le 27/04/2006 20:05:39 et modifié le 27/04/2006
consulté 8191 fois
Niveau
initié
Version(s) Foxpro : VFP 9.0 VFP 8.0 VFP 7.0 VFP 6.0
|
Description |
Ce code a besoin de WMI et doit etre roulé à partir d'une station XP ou Windows 2003 |
Code source : |
local oWMI, cAddress, oPings, oPing, oItem
CLEAR
oWMI = getobject("winmgmts:")
cAddress = "www.mcrgsoftware.com" && Ou adresse IP
if os() < "Windows 5.01" or os() = "Windows NT 4.00"
messagebox("Ceci fonctionne seulement sur Windows XP/Server 2003")
return
endif
oPings = oWMI.ExecQuery([Select * from WIN32_Pingstatus where address='] + cAddress + ['])
for each oPing in oPings
* Cette classe ne supporte pas le For/Each puisqu'il y a seulement une réponse à recevoir
? "Code de Statut: ", GetStatusCode(oPing.statuscode)
?
? "Adresse: ", oPing.Address
? "Buffer size", oPing.BufferSize
? "No Fragmentation", oPing.NoFragmentation
? "PrimaryAddressResolutionStatus", oPing.PrimaryAddressResolutionStatus
? "ProtocolAddress", oPing.ProtocolAddress
? "ProtocolAddressResolved", oPing.ProtocolAddressResolved
? "RecordRoute", oPing.RecordRoute
? "ReplyInconsistency", oPing.ReplyInconsistency
? "ReplySize", oPing.ReplySize
? "ResolveAddressNames", oPing.ResolveAddressNames
? "ResponseTime", oPing.ResponseTime
? "ResponseTimeToLive", oPing.ResponseTimeToLive
? "SourceRoute", oPing.SourceRoute
? "SourceRouteType", GetSourceRouteType(oPing.SourceRouteType)
? "Timeout", oPing.timeout
? "TimestampRoute", oPing.TimestampRoute
? "TimeToLive", oPing.TimeToLive
? "TypeofService", GetTypeOfService(oPing.TypeofService)
if not isnull(oPing.RouteRecord)
for each oItem in oPing.RouteRecord
? oItem
next
endif
if not isnull(oPing.RouteRecordResolved)
for each oItem in oPing.RouteRecordResolved
? oItem
next
endif
if not isnull(oPing.RouteRecordResolved)
for each oItem in oPing.TimeStampRecord
? oItem
next
endif
if not isnull(oPing.TimeStampRecordAddress)
for each oItem in oPing.TimeStampRecordAddress
? oItem
next
endif
if not isnull(oPing.TimeStampRecordAddressResolved)
for each oItem in oPing.TimeStampRecordAddressResolved
? oItem
next
endif
next
procedure GetSourceRouteType
lparameters nSourceRouteType
local cType
do case
case nSourceRouteType = 1
cType = "Loose Source Routing"
case nSourceRouteType = 2
cType = "Strict Source Routing"
otherwise
* Defaut - 0 - ou autre valeur.
cType = "Aucun"
endcase
return cType
endproc
procedure GetTypeOfService
lparameters nServiceType
local cType as string
do case
case nServiceType = 2
cType = "Minimize Monetary Cost"
case nServiceType = 4
cType = "Maximize Reliability"
case nServiceType = 8
cType = "Maximize Throughput"
case nServiceType = 16
cType = "Minimize Delay"
otherwise
* Default - 0 - or any other value.
cType = "Normal"
endcase
return cType
endproc
procedure GetStatusCode (cCode as string) as string
local cStatus
do case
case cCode = 0
cStatus = "Success"
case cCode = 11001
cStatus = "Buffer Too Small"
case cCode = 11002
cStatus = "Destination Net Unreachable"
case cCode = 11003
cStatus = "Destination Host Unreachable"
case cCode = 11004
cStatus = "Destination Protocol Unreachable"
case cCode = 11005
cStatus = "Destination Port Unreachable"
case cCode = 11006
cStatus = "No Resources"
case cCode = 11007
cStatus = "Bad Option"
case cCode = 11008
cStatus = "Hardware Error"
case cCode = 11009
cStatus = "Packet Too Big"
case cCode = 11010
cStatus = "Request Timed Out"
case cCode = 11011
cStatus = "Bad Request"
case cCode = 11012
cStatus = "Bad Route"
case cCode = 11013
cStatus = "TimeToLive Expired Transit"
case cCode = 11014
cStatus = "TimeToLive Expired Reassembly"
case cCode = 11015
cStatus = "Parameter Problem"
case cCode = 11016
cStatus = "Source Quench"
case cCode = 11017
cStatus = "Option Too Big"
case cCode = 11018
cStatus = "Bad Destination"
case cCode = 11032
cStatus = "Negotiating IPSEC"
case cCode = 11050
cStatus = "General Failure"
otherwise
cStatus = "Unknown"
endcase
return cStatus
endproc
--
|
Commentaires |
Aucun commentaire enregistré ...
|