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