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

GetFriendlyIfIndex

関数
インターフェイス索引を扱いやすい簡略索引に変換する。
DLLIPHLPAPI.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

DWORD GetFriendlyIfIndex(
    DWORD IfIndex
);

パラメーター

名前方向
IfIndexDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

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

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

GetFriendlyIfIndex = ctypes.windll.iphlpapi.GetFriendlyIfIndex
GetFriendlyIfIndex.restype = wintypes.DWORD
GetFriendlyIfIndex.argtypes = [
    wintypes.DWORD,  # IfIndex : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
	procGetFriendlyIfIndex = iphlpapi.NewProc("GetFriendlyIfIndex")
)

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