ホーム › NetworkManagement.IpHelper › GetNumberOfInterfaces
GetNumberOfInterfaces
関数システム上のネットワークインターフェイス数を取得する。
シグネチャ
// IPHLPAPI.dll
#include <windows.h>
DWORD GetNumberOfInterfaces(
DWORD* pdwNumIf
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pdwNumIf | DWORD* | out |
戻り値の型: DWORD
各言語での呼び出し定義
// IPHLPAPI.dll
#include <windows.h>
DWORD GetNumberOfInterfaces(
DWORD* pdwNumIf
);[DllImport("IPHLPAPI.dll", ExactSpelling = true)]
static extern uint GetNumberOfInterfaces(
out uint pdwNumIf // DWORD* out
);<DllImport("IPHLPAPI.dll", ExactSpelling:=True)>
Public Shared Function GetNumberOfInterfaces(
<Out> ByRef pdwNumIf As UInteger ' DWORD* out
) As UInteger
End Function' pdwNumIf : DWORD* out
Declare PtrSafe Function GetNumberOfInterfaces Lib "iphlpapi" ( _
ByRef pdwNumIf As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetNumberOfInterfaces = ctypes.windll.iphlpapi.GetNumberOfInterfaces
GetNumberOfInterfaces.restype = wintypes.DWORD
GetNumberOfInterfaces.argtypes = [
ctypes.POINTER(wintypes.DWORD), # pdwNumIf : DWORD* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('IPHLPAPI.dll')
GetNumberOfInterfaces = Fiddle::Function.new(
lib['GetNumberOfInterfaces'],
[
Fiddle::TYPE_VOIDP, # pdwNumIf : DWORD* out
],
-Fiddle::TYPE_INT)#[link(name = "iphlpapi")]
extern "system" {
fn GetNumberOfInterfaces(
pdwNumIf: *mut u32 // DWORD* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("IPHLPAPI.dll")]
public static extern uint GetNumberOfInterfaces(out uint pdwNumIf);
"@
$api = Add-Type -MemberDefinition $sig -Name 'IPHLPAPI_GetNumberOfInterfaces' -Namespace Win32 -PassThru
# $api::GetNumberOfInterfaces(pdwNumIf)#uselib "IPHLPAPI.dll"
#func global GetNumberOfInterfaces "GetNumberOfInterfaces" sptr
; GetNumberOfInterfaces varptr(pdwNumIf) ; 戻り値は stat
; pdwNumIf : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "IPHLPAPI.dll" #cfunc global GetNumberOfInterfaces "GetNumberOfInterfaces" var ; res = GetNumberOfInterfaces(pdwNumIf) ; pdwNumIf : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "IPHLPAPI.dll" #cfunc global GetNumberOfInterfaces "GetNumberOfInterfaces" sptr ; res = GetNumberOfInterfaces(varptr(pdwNumIf)) ; pdwNumIf : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD GetNumberOfInterfaces(DWORD* pdwNumIf) #uselib "IPHLPAPI.dll" #cfunc global GetNumberOfInterfaces "GetNumberOfInterfaces" var ; res = GetNumberOfInterfaces(pdwNumIf) ; pdwNumIf : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD GetNumberOfInterfaces(DWORD* pdwNumIf) #uselib "IPHLPAPI.dll" #cfunc global GetNumberOfInterfaces "GetNumberOfInterfaces" intptr ; res = GetNumberOfInterfaces(varptr(pdwNumIf)) ; pdwNumIf : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
procGetNumberOfInterfaces = iphlpapi.NewProc("GetNumberOfInterfaces")
)
// pdwNumIf (DWORD* out)
r1, _, err := procGetNumberOfInterfaces.Call(
uintptr(pdwNumIf),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction GetNumberOfInterfaces(
pdwNumIf: Pointer // DWORD* out
): DWORD; stdcall;
external 'IPHLPAPI.dll' name 'GetNumberOfInterfaces';result := DllCall("IPHLPAPI\GetNumberOfInterfaces"
, "Ptr", pdwNumIf ; DWORD* out
, "UInt") ; return: DWORD●GetNumberOfInterfaces(pdwNumIf) = DLL("IPHLPAPI.dll", "dword GetNumberOfInterfaces(void*)")
# 呼び出し: GetNumberOfInterfaces(pdwNumIf)
# pdwNumIf : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。