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

ConvertInterfaceLuidToAlias

関数
インターフェイスLUIDをエイリアス(別名)に変換する。
DLLIPHLPAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

WIN32_ERROR ConvertInterfaceLuidToAlias(
    const NET_LUID_LH* InterfaceLuid,
    LPWSTR InterfaceAlias,
    UINT_PTR Length
);

パラメーター

名前方向説明
InterfaceLuidNET_LUID_LH*in変換元のインターフェイスを識別するNET_LUIDへのポインタ。
InterfaceAliasLPWSTRout対応するインターフェイスのエイリアス(別名)を受け取るワイド文字バッファへのポインタ。
LengthUINT_PTRinInterfaceAliasバッファの長さ(文字数)。

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

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

WIN32_ERROR ConvertInterfaceLuidToAlias(
    const NET_LUID_LH* InterfaceLuid,
    LPWSTR InterfaceAlias,
    UINT_PTR Length
);
[DllImport("IPHLPAPI.dll", ExactSpelling = true)]
static extern uint ConvertInterfaceLuidToAlias(
    IntPtr InterfaceLuid,   // NET_LUID_LH*
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder InterfaceAlias,   // LPWSTR out
    UIntPtr Length   // UINT_PTR
);
<DllImport("IPHLPAPI.dll", ExactSpelling:=True)>
Public Shared Function ConvertInterfaceLuidToAlias(
    InterfaceLuid As IntPtr,   ' NET_LUID_LH*
    <MarshalAs(UnmanagedType.LPWStr)> InterfaceAlias As System.Text.StringBuilder,   ' LPWSTR out
    Length As UIntPtr   ' UINT_PTR
) As UInteger
End Function
' InterfaceLuid : NET_LUID_LH*
' InterfaceAlias : LPWSTR out
' Length : UINT_PTR
Declare PtrSafe Function ConvertInterfaceLuidToAlias Lib "iphlpapi" ( _
    ByVal InterfaceLuid As LongPtr, _
    ByVal InterfaceAlias As LongPtr, _
    ByVal Length As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ConvertInterfaceLuidToAlias = ctypes.windll.iphlpapi.ConvertInterfaceLuidToAlias
ConvertInterfaceLuidToAlias.restype = wintypes.DWORD
ConvertInterfaceLuidToAlias.argtypes = [
    ctypes.c_void_p,  # InterfaceLuid : NET_LUID_LH*
    wintypes.LPWSTR,  # InterfaceAlias : LPWSTR out
    ctypes.c_size_t,  # Length : UINT_PTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
	procConvertInterfaceLuidToAlias = iphlpapi.NewProc("ConvertInterfaceLuidToAlias")
)

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