Win32 API 日本語リファレンス
ホームNetworkManagement.IpHelper › GetIcmpStatistics

GetIcmpStatistics

関数
ICMPプロトコルの統計情報を取得する。
DLLIPHLPAPI.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// IPHLPAPI.dll
#include <windows.h>

DWORD GetIcmpStatistics(
    MIB_ICMP* Statistics
);

パラメーター

名前方向
StatisticsMIB_ICMP*out

戻り値の型: DWORD

各言語での呼び出し定義

// IPHLPAPI.dll
#include <windows.h>

DWORD GetIcmpStatistics(
    MIB_ICMP* Statistics
);
[DllImport("IPHLPAPI.dll", ExactSpelling = true)]
static extern uint GetIcmpStatistics(
    IntPtr Statistics   // MIB_ICMP* out
);
<DllImport("IPHLPAPI.dll", ExactSpelling:=True)>
Public Shared Function GetIcmpStatistics(
    Statistics As IntPtr   ' MIB_ICMP* out
) As UInteger
End Function
' Statistics : MIB_ICMP* out
Declare PtrSafe Function GetIcmpStatistics Lib "iphlpapi" ( _
    ByVal Statistics As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetIcmpStatistics = ctypes.windll.iphlpapi.GetIcmpStatistics
GetIcmpStatistics.restype = wintypes.DWORD
GetIcmpStatistics.argtypes = [
    ctypes.c_void_p,  # Statistics : MIB_ICMP* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('IPHLPAPI.dll')
GetIcmpStatistics = Fiddle::Function.new(
  lib['GetIcmpStatistics'],
  [
    Fiddle::TYPE_VOIDP,  # Statistics : MIB_ICMP* out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "iphlpapi")]
extern "system" {
    fn GetIcmpStatistics(
        Statistics: *mut MIB_ICMP  // MIB_ICMP* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("IPHLPAPI.dll")]
public static extern uint GetIcmpStatistics(IntPtr Statistics);
"@
$api = Add-Type -MemberDefinition $sig -Name 'IPHLPAPI_GetIcmpStatistics' -Namespace Win32 -PassThru
# $api::GetIcmpStatistics(Statistics)
#uselib "IPHLPAPI.dll"
#func global GetIcmpStatistics "GetIcmpStatistics" sptr
; GetIcmpStatistics varptr(Statistics)   ; 戻り値は stat
; Statistics : MIB_ICMP* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "IPHLPAPI.dll"
#cfunc global GetIcmpStatistics "GetIcmpStatistics" var
; res = GetIcmpStatistics(Statistics)
; Statistics : MIB_ICMP* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD GetIcmpStatistics(MIB_ICMP* Statistics)
#uselib "IPHLPAPI.dll"
#cfunc global GetIcmpStatistics "GetIcmpStatistics" var
; res = GetIcmpStatistics(Statistics)
; Statistics : MIB_ICMP* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
	procGetIcmpStatistics = iphlpapi.NewProc("GetIcmpStatistics")
)

// Statistics (MIB_ICMP* out)
r1, _, err := procGetIcmpStatistics.Call(
	uintptr(Statistics),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function GetIcmpStatistics(
  Statistics: Pointer   // MIB_ICMP* out
): DWORD; stdcall;
  external 'IPHLPAPI.dll' name 'GetIcmpStatistics';
result := DllCall("IPHLPAPI\GetIcmpStatistics"
    , "Ptr", Statistics   ; MIB_ICMP* out
    , "UInt")   ; return: DWORD
●GetIcmpStatistics(Statistics) = DLL("IPHLPAPI.dll", "dword GetIcmpStatistics(void*)")
# 呼び出し: GetIcmpStatistics(Statistics)
# Statistics : MIB_ICMP* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。