ICMP統計値を取得          <TOP>


GetIcmpStatistics ICMP(Internet Control Message Protocol)統計値を取得

 

 

'================================================================
'= ICMP統計値を取得
'=    (GetIcmpStatistics.bas)
'================================================================
#include "Windows.bi"

Type MIBICMPSTATS
    dwMsgs          As Long
    dwErrors        As Long
    dwDestUnreachs  As Long
    dwTimeExcds     As Long
    dwParmProbs     As Long
    dwSrcQuenchs    As Long
    dwRedirects     As Long
    dwEchos         As Long
    dwEchoReps      As Long
    dwTimestamps    As Long
    dwTimestampReps As Long
    dwAddrMasks     As Long
    dwAddrMaskReps  As Long
End Type

Type MIBICMPINFO
    icmpInStats  As MIBICMPSTATS
    icmpOutStats As MIBICMPSTATS
End Type

Type MIB_ICMP
    stats As MIBICMPINFO
End Type

' ICMP(Internet Control Message Protocol)統計値を取得
Declare Function Api_GetIcmpStatistics& Lib "iphlpapi" Alias "GetIcmpStatistics" (pStats As MIB_ICMP)

Var Shared List1 As Object
Var Shared Button1 As Object

List1.Attach GetDlgItem("List1") : List1.SetFontSize 14
Button1.Attach GetDlgItem("Button1") : Button1.SetFontSize 14

'================================================================
'=
'================================================================
Declare Sub Button1_on edecl ()
Sub Button1_on()
    Var mi As MIB_ICMP
    Var Item As String
    Var Ret As Long

    List1.Resetcontent

    'ICMP統計値を取得
    Ret = Api_GetIcmpStatistics(mi)

    '[in] Msgsを表示
    Item = Trim$(Str$(mi.stats.icmpInStats.dwMsgs))
    List1.AddString "[in] Msgs          : " & Item

    '[in] Errorsを表示
    Item = Trim$(Str$(mi.stats .icmpInStats.dwErrors))
    List1.AddString "[in] Errors        : " & Item

    '[in] DestUnreachsを表示
    Item = Trim$(Str$(mi.stats.icmpInStats.dwDestUnreachs))
    List1.AddString "[in] Errors        : " & Item

    '[in] TimeExcdsを表示
    Item = Trim$(Str$(mi.stats.icmpInStats.dwTimeExcds))
    List1.AddString "[in] TimeExcds     : " & Item

    '[in] ParmProbsを表示
    Item = Trim$(Str$(mi.stats.icmpInStats.dwParmProbs))
    List1.AddString "[in] ParmProbs     : " & Item

    '[in] SrcQuenchsを表示
    Item = Trim$(Str$(mi.stats.icmpInStats.dwSrcQuenchs))
    List1.AddString "[in] SrcQuenchs    : " & Item

    '[in] Redirectsを表示
    Item = Trim$(Str$(mi.stats.icmpInStats.dwRedirects))
    List1.AddString "[in] Redirects     : " & Item

    '[in] Echosを表示
    Item = Trim$(Str$(mi.stats.icmpInStats.dwEchos))
    List1.AddString "[in] Echos         : " & Item

    '[in] EchoRepsを表示
    Item = Trim$(Str$(mi.stats.icmpInStats.dwEchoReps))
    List1.AddString "[in] EchoReps      : " & Item

    '[in] Timestampsを表示
    Item = Trim$(Str$(mi.stats.icmpInStats.dwTimestamps))
    List1.AddString "[in] Timestamps    : " & Item

    '[in] TimestampRepsを表示
    Item = Trim$(Str$(mi.stats.icmpInStats.dwTimestampReps))
    List1.AddString "[in] TimestampReps : " & Item

    '[in] AddrMasksを表示
    Item = Trim$(Str$(mi.stats.icmpInStats.dwAddrMasks))
    List1.AddString "[in] AddrMasks     : " & Item

    '[in] AddrMaskRepsを表示
    Item = Trim$(Str$(mi.stats.icmpInStats.dwAddrMaskReps))
    List1.AddString "[in] AddrMaskReps  : " & Item

    '[out] Msgsを表示
    Item = Trim$(Str$(mi.stats.icmpOutStats.dwMsgs))
    List1.AddString "[out] Msgs         : " & Item

    '[out] Errorsを表示
    Item = Trim$(Str$(mi.stats.icmpOutStats.dwErrors))
    List1.AddString "[out] Errors       : " & Item

    '[out] DestUnreachsを表示
    Item = Trim$(Str$(mi.stats.icmpOutStats.dwDestUnreachs))
    List1.AddString "[out] DestUnreachs : " & Item

    '[out] TimeExcdsを表示
    Item = Trim$(Str$(mi.stats.icmpOutStats.dwTimeExcds))
    List1.AddString "[out] TimeExcds    : " & Item

    '[out] ParmProbsを表示
    Item = Trim$(Str$(mi.stats.icmpOutStats.dwParmProbs))
    List1.AddString "[out] ParmProbs    : " & Item

    '[out] SrcQuenchsを表示
    Item = Trim$(Str$(mi.stats.icmpOutStats.dwSrcQuenchs))
    List1.AddString "[out] SrcQuenchs   : " & Item

    '[out] Redirectsを表示
    Item = Trim$(Str$(mi.stats.icmpOutStats.dwRedirects))
    List1.AddString "[out] SrcQuenchs   : " & Item

    '[out] Echosを表示
    Item = Trim$(Str$(mi.stats.icmpOutStats.dwEchos))
    List1.AddString "[out] Echos        : " & Item

    '[out] EchoRepsを表示
    Item = Trim$(Str$(mi.stats.icmpOutStats.dwEchoReps))
    List1.AddString "[out] EchoReps     : " & Item

    '[out] Timestampsを表示
    Item = Trim$(Str$(mi.stats.icmpOutStats.dwTimestamps))
    List1.AddString "[out] Timestamps   : " & Item

    '[out] TimestampRepsを表示
    Item = Trim$(Str$(mi.stats.icmpOutStats.dwTimestampReps))
    List1.AddString "[out] TimestampReps: " & Item

    '[out] AddrMasksを表示
    Item = Trim$(Str$(mi.stats.icmpOutStats.dwAddrMasks))
    List1.AddString "[out] AddrMasks    : " & Item

    '[out] AddrMaskRepsを表示
    Item = Trim$(Str$(mi.stats.icmpOutStats.dwAddrMaskReps))
    List1.AddString "[out] AddrMaskReps : " & Item
End Sub

'================================================================
'=
'================================================================
While 1
    WaitEvent
Wend
Stop
End