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

IcmpCreateFile

関数
ICMPエコー要求送信用のハンドルを作成する。
DLLIPHLPAPI.dll呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

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

HANDLE IcmpCreateFile(void);

パラメーターなし。戻り値: HANDLE

各言語での呼び出し定義

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

HANDLE IcmpCreateFile(void);
[DllImport("IPHLPAPI.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr IcmpCreateFile();
<DllImport("IPHLPAPI.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function IcmpCreateFile() As IntPtr
End Function
Declare PtrSafe Function IcmpCreateFile Lib "iphlpapi" () As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

IcmpCreateFile = ctypes.windll.iphlpapi.IcmpCreateFile
IcmpCreateFile.restype = ctypes.c_void_p
IcmpCreateFile.argtypes = []
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('IPHLPAPI.dll')
IcmpCreateFile = Fiddle::Function.new(
  lib['IcmpCreateFile'],
  [],
  Fiddle::TYPE_VOIDP)
#[link(name = "iphlpapi")]
extern "system" {
    fn IcmpCreateFile() -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("IPHLPAPI.dll", SetLastError = true)]
public static extern IntPtr IcmpCreateFile();
"@
$api = Add-Type -MemberDefinition $sig -Name 'IPHLPAPI_IcmpCreateFile' -Namespace Win32 -PassThru
# $api::IcmpCreateFile()
#uselib "IPHLPAPI.dll"
#func global IcmpCreateFile "IcmpCreateFile"
; IcmpCreateFile   ; 戻り値は stat
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "IPHLPAPI.dll"
#cfunc global IcmpCreateFile "IcmpCreateFile"
; res = IcmpCreateFile()
; HANDLE IcmpCreateFile()
#uselib "IPHLPAPI.dll"
#cfunc global IcmpCreateFile "IcmpCreateFile"
; res = IcmpCreateFile()
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
	procIcmpCreateFile = iphlpapi.NewProc("IcmpCreateFile")
)

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