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

ConvertInterfaceGuidToLuid

関数
インターフェイスGUIDをLUIDに変換する。
DLLIPHLPAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

WIN32_ERROR ConvertInterfaceGuidToLuid(
    const GUID* InterfaceGuid,
    NET_LUID_LH* InterfaceLuid
);

パラメーター

名前方向
InterfaceGuidGUID*in
InterfaceLuidNET_LUID_LH*out

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

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

WIN32_ERROR ConvertInterfaceGuidToLuid(
    const GUID* InterfaceGuid,
    NET_LUID_LH* InterfaceLuid
);
[DllImport("IPHLPAPI.dll", ExactSpelling = true)]
static extern uint ConvertInterfaceGuidToLuid(
    ref Guid InterfaceGuid,   // GUID*
    IntPtr InterfaceLuid   // NET_LUID_LH* out
);
<DllImport("IPHLPAPI.dll", ExactSpelling:=True)>
Public Shared Function ConvertInterfaceGuidToLuid(
    ByRef InterfaceGuid As Guid,   ' GUID*
    InterfaceLuid As IntPtr   ' NET_LUID_LH* out
) As UInteger
End Function
' InterfaceGuid : GUID*
' InterfaceLuid : NET_LUID_LH* out
Declare PtrSafe Function ConvertInterfaceGuidToLuid Lib "iphlpapi" ( _
    ByVal InterfaceGuid As LongPtr, _
    ByVal InterfaceLuid As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ConvertInterfaceGuidToLuid = ctypes.windll.iphlpapi.ConvertInterfaceGuidToLuid
ConvertInterfaceGuidToLuid.restype = wintypes.DWORD
ConvertInterfaceGuidToLuid.argtypes = [
    ctypes.c_void_p,  # InterfaceGuid : GUID*
    ctypes.c_void_p,  # InterfaceLuid : NET_LUID_LH* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
	procConvertInterfaceGuidToLuid = iphlpapi.NewProc("ConvertInterfaceGuidToLuid")
)

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