GetUnicastIpAddressEntry
関数シグネチャ
// IPHLPAPI.dll
#include <windows.h>
WIN32_ERROR GetUnicastIpAddressEntry(
MIB_UNICASTIPADDRESS_ROW* Row
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Row | MIB_UNICASTIPADDRESS_ROW* | inout | ユニキャスト IP アドレスエントリを表す MIB_UNICASTIPADDRESS_ROW 構造体エントリへのポインター。正常に返ったとき、この構造体には既存のユニキャスト IP アドレスのプロパティが設定されます。 |
戻り値の型: WIN32_ERROR
公式ドキュメント
ローカルコンピューター上に存在するユニキャスト IP アドレスエントリの情報を取得します。
戻り値
関数が成功した場合、戻り値は NO_ERROR です。
関数が失敗した場合、戻り値は次のいずれかのエラーコードになります。
| 戻り値 | 説明 |
|---|---|
| 指定されたファイルが見つかりません。このエラーは、Row パラメーターが指す MIB_UNICASTIPADDRESS_ROW の InterfaceLuid または InterfaceIndex メンバーで指定されたネットワークインターフェイスの LUID またはインターフェイスインデックスが、ローカルマシン上に存在する値ではない場合に返されます。 | |
| パラメーターが正しくありません。このエラーは、Row パラメーターに NULL ポインターが渡された場合、Row パラメーターが指す MIB_UNICASTIPADDRESS_ROW の Address メンバーが有効なユニキャスト IPv4 または IPv6 アドレスに設定されていない場合、あるいは Row パラメーターが指す MIB_UNICASTIPADDRESS_ROW の InterfaceLuid メンバーと InterfaceIndex メンバーの両方が未指定の場合に返されます。 | |
| 要素が見つかりません。このエラーは、Row パラメーターが指す MIB_UNICASTIPADDRESS_ROW 構造体の InterfaceLuid または InterfaceIndex メンバーで指定されたネットワークインターフェイスが、MIB_UNICASTIPADDRESS_ROW 構造体の Address メンバーで指定された IP アドレスと一致しない場合に返されます。 | |
| 要求はサポートされていません。このエラーは、ローカルコンピューターに IPv4 スタックが存在せず、Row パラメーターが指す MIB_UNICASTIPADDRESS_ROW 構造体の Address メンバーに IPv4 アドレスが指定されている場合に返されます。また、ローカルコンピューターに IPv6 スタックが存在せず、Address メンバーに IPv6 アドレスが指定されている場合にも返されます。 | |
|
返されたエラーのメッセージ文字列を取得するには、 FormatMessage を使用してください。 |
解説(Remarks)
GetUnicastIpAddressEntry 関数は Windows Vista 以降で定義されています。
GetUnicastIpAddressEntry 関数は通常、変更対象となる既存の MIB_UNICASTIPADDRESS_ROW 構造体エントリを取得するために使用します。アプリケーションは、変更したい MIB_UNICASTIPADDRESS_ROW エントリのメンバーを変更した後、SetUnicastIpAddressEntry 関数を呼び出すことができます。
入力時には、Row パラメーターが指す MIB_UNICASTIPADDRESS_ROW 構造体の Address メンバーを、有効なユニキャスト IPv4 または IPv6 アドレスに初期化しておく必要があります。Address メンバー内の SOCKADDR_INET 構造体の si_family メンバーを AF_INET または AF_INET6 のいずれかに初期化し、SOCKADDR_INET 構造体の対応する Ipv4 または Ipv6 メンバーを有効なユニキャスト IP アドレスに設定する必要があります。さらに、Row パラメーターが指す MIB_UNICASTIPADDRESS_ROW 構造体の次のメンバーのうち、少なくとも 1 つを初期化する必要があります。すなわち InterfaceLuid または InterfaceIndex です。
これらのフィールドは上記の順序で使用されます。したがって、InterfaceLuid が指定されている場合は、このメンバーを使用してインターフェイスが特定されます。InterfaceLuid メンバーに値が設定されていない場合(このメンバーの値がゼロに設定されている場合)は、次に InterfaceIndex メンバーを使用してインターフェイスが特定されます。
呼び出しが成功した場合の出力では、GetUnicastIpAddressEntry はユニキャスト IP アドレスのその他のプロパティを取得し、Row パラメーターが指す MIB_UNICASTIPADDRESS_ROW 構造体に値を設定します。
ローカルコンピューター上のユニキャスト IP アドレスエントリを列挙するには、GetUnicastIpAddressTable 関数を呼び出すことができます。
例
次の例では、コマンドラインで指定されたユニキャスト IP アドレスエントリを取得し、取得した MIB_UNICASTIPADDRESS_ROW 構造体からいくつかの値を出力します。
#ifndef UNICODE
#define UNICODE
#endif
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <Windows.h.>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <ws2ipdef.h>
#include <iphlpapi.h>
#include <stdio.h>
#include <stdlib.h>
// Need to link with Iphlpapi.lib and Ws2_32.lib
#pragma comment (lib, "iphlpapi.lib")
#pragma comment (lib, "Ws2_32.lib")
void PrintUnicastIpAddress(PMIB_UNICASTIPADDRESS_ROW pIpRow);
int __cdecl wmain(int argc, WCHAR **argv)
{
// Declare and initialize variables
ULONG Result = 0;
ULONG ifIndex;
// default to unspecified address family
ULONG addressFamily = AF_UNSPEC;
IN_ADDR Ipv4Addr;
IN6_ADDR Ipv6Addr;
MIB_UNICASTIPADDRESS_ROW ipRow = {0};
// Validate the parameters
if (argc < 4) {
wprintf(L"usage: %s <AddressFamily> <IPAddress> <InterfaceIndex>\n", argv[0]);
wprintf(L" Gets the UnicastIpAddressEntry for an AddressFamily,\n");
wprintf(L" Interface Index, and IP address\n");
wprintf(L" Examples\n");
wprintf(L" Get the IPv4 loopback at interface index=1\n");
wprintf(L" %s 4 127.0.0.1 1\n", argv[0]);
wprintf(L" Get the IPv6 loopback at interface index=1\n");
wprintf(L" %s 6 ::1 1\n", argv[0]);
exit(1);
}
if (_wtoi(argv[1]) == 4) {
addressFamily = AF_INET;
if (InetPtonW(addressFamily, argv[2], &Ipv4Addr) != 1) {
wprintf(L"Unable to parse IPv4 address string: %s\n", argv[3]);
exit(1);
}
} else if (_wtoi(argv[1]) == 6) {
addressFamily = AF_INET6;
if (InetPton(addressFamily, argv[2], &Ipv6Addr) != 1) {
wprintf(L"Unable to parse IPv6 address string: %s\n", argv[3]);
exit(1);
}
}
ifIndex = _wtoi(argv[3]);
ipRow.Address.si_family = (ADDRESS_FAMILY) addressFamily;
ipRow.InterfaceIndex = ifIndex;
if (addressFamily == AF_INET) {
ipRow.Address.si_family = AF_INET;
memcpy(&ipRow.Address.Ipv4.sin_addr, &Ipv4Addr, sizeof (IN_ADDR));
}
if (addressFamily == AF_INET6) {
ipRow.Address.si_family = AF_INET6;
memcpy(&ipRow.Address.Ipv6.sin6_addr, &Ipv6Addr, sizeof (IN6_ADDR));
}
Result = GetUnicastIpAddressEntry(&ipRow);
if (Result != NO_ERROR) {
wprintf(L"GetUnicastIpAddressEntry returned error: %lu\n", Result);
exit(1);
}
PrintUnicastIpAddress(&ipRow);
exit(0);
}
void PrintUnicastIpAddress(PMIB_UNICASTIPADDRESS_ROW pipRow)
{
WCHAR Ipv4String[16] = { 0 };
WCHAR Ipv6String[46] = { 0 };
// Print some variables from the rows in the table
wprintf(L"AddressFamily:\t\t\t ");
switch (pipRow->Address.si_family) {
case AF_INET:
wprintf(L"IPv4\n");
if (InetNtop(AF_INET, &pipRow->Address.Ipv4.sin_addr, Ipv4String, 16) !=
NULL)
wprintf(L"IPv4 Address:\t\t\t %ws\n", Ipv4String);
break;
case AF_INET6:
wprintf(L"IPv6\n");
if (InetNtop(AF_INET6, &pipRow->Address.Ipv6.sin6_addr, Ipv6String, 46)
!= NULL)
wprintf(L"IPv6 Address:\t\t\t %s\n", Ipv6String);
break;
default:
wprintf(L"Other: %d\n", pipRow->Address.si_family);
break;
}
wprintf(L"Interface LUID NetLuidIndex:\t %lu\n",
pipRow->InterfaceLuid.Info.NetLuidIndex);
wprintf(L"Interface LUID IfType:\t\t ");
switch (pipRow->InterfaceLuid.Info.IfType) {
case IF_TYPE_OTHER:
wprintf(L"Other\n");
break;
case IF_TYPE_ETHERNET_CSMACD:
wprintf(L"Ethernet\n");
break;
case IF_TYPE_ISO88025_TOKENRING:
wprintf(L"Token ring\n");
break;
case IF_TYPE_PPP:
wprintf(L"PPP\n");
break;
case IF_TYPE_SOFTWARE_LOOPBACK:
wprintf(L"Software loopback\n");
break;
case IF_TYPE_ATM:
wprintf(L"ATM\n");
break;
case IF_TYPE_IEEE80211:
wprintf(L"802.11 wireless\n");
break;
case IF_TYPE_TUNNEL:
wprintf(L"Tunnel encapsulation\n");
break;
case IF_TYPE_IEEE1394:
wprintf(L"IEEE 1394 (Firewire)\n");
break;
default:
wprintf(L"Unknown: %d\n", pipRow->InterfaceLuid.Info.IfType);
break;
}
wprintf(L"Interface Index:\t\t %lu\n", pipRow->InterfaceIndex);
wprintf(L"Prefix Origin:\t\t\t ");
switch (pipRow->PrefixOrigin) {
case IpPrefixOriginOther:
wprintf(L"IpPrefixOriginOther\n");
break;
case IpPrefixOriginManual:
wprintf(L"IpPrefixOriginManual\n");
break;
case IpPrefixOriginWellKnown:
wprintf(L"IpPrefixOriginWellKnown\n");
break;
case IpPrefixOriginDhcp:
wprintf(L"IpPrefixOriginDhcp\n");
break;
case IpPrefixOriginRouterAdvertisement:
wprintf(L"IpPrefixOriginRouterAdvertisement\n");
break;
case IpPrefixOriginUnchanged:
wprintf(L"IpPrefixOriginUnchanged\n");
break;
default:
wprintf(L"Unknown: %d\n", pipRow->PrefixOrigin);
break;
}
wprintf(L"Suffix Origin:\t\t\t ");
switch (pipRow->SuffixOrigin) {
case IpSuffixOriginOther:
wprintf(L"IpSuffixOriginOther\n");
break;
case IpSuffixOriginManual:
wprintf(L"IpSuffixOriginManual\n");
break;
case IpSuffixOriginWellKnown:
wprintf(L"IpSuffixOriginWellKnown\n");
break;
case IpSuffixOriginDhcp:
wprintf(L"IpSuffixOriginDhcp\n");
break;
case IpSuffixOriginLinkLayerAddress:
wprintf(L"IpSuffixOriginLinkLayerAddress\n");
break;
case IpSuffixOriginRandom:
wprintf(L"IpSuffixOriginRandom\n");
break;
case IpSuffixOriginUnchanged:
wprintf(L"IpSuffixOriginUnchanged\n");
break;
default:
wprintf(L"Unknown: %d\n", pipRow->SuffixOrigin);
break;
}
wprintf(L"Valid Lifetime:\t\t\t 0x%x (%u)\n",
pipRow->ValidLifetime, pipRow->ValidLifetime);
wprintf(L"Preferred Lifetime:\t\t 0x%x (%u)\n",
pipRow->PreferredLifetime, pipRow->PreferredLifetime);
wprintf(L"OnLink PrefixLength:\t\t %lu\n", pipRow->OnLinkPrefixLength);
wprintf(L"Skip As Source:\t\t\t ");
if (pipRow->SkipAsSource)
wprintf(L"Yes\n");
else
wprintf(L"No\n");
wprintf(L"Dad State:\t\t\t ");
switch (pipRow->DadState) {
case IpDadStateInvalid:
wprintf(L"IpDadStateInvalid\n");
break;
case IpDadStateTentative:
wprintf(L"IpDadStateTentative\n");
break;
case IpDadStateDuplicate:
wprintf(L"IpDadStateDuplicate\n");
break;
case IpDadStateDeprecated:
wprintf(L"IpDadStateDeprecated\n");
break;
case IpDadStatePreferred:
wprintf(L"IpDadStatePreferred\n");
break;
default:
wprintf(L"Unknown: %d\n", pipRow->DadState);
break;
}
wprintf(L"\n");
}
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// IPHLPAPI.dll
#include <windows.h>
WIN32_ERROR GetUnicastIpAddressEntry(
MIB_UNICASTIPADDRESS_ROW* Row
);[DllImport("IPHLPAPI.dll", ExactSpelling = true)]
static extern uint GetUnicastIpAddressEntry(
IntPtr Row // MIB_UNICASTIPADDRESS_ROW* in/out
);<DllImport("IPHLPAPI.dll", ExactSpelling:=True)>
Public Shared Function GetUnicastIpAddressEntry(
Row As IntPtr ' MIB_UNICASTIPADDRESS_ROW* in/out
) As UInteger
End Function' Row : MIB_UNICASTIPADDRESS_ROW* in/out
Declare PtrSafe Function GetUnicastIpAddressEntry Lib "iphlpapi" ( _
ByVal Row As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetUnicastIpAddressEntry = ctypes.windll.iphlpapi.GetUnicastIpAddressEntry
GetUnicastIpAddressEntry.restype = wintypes.DWORD
GetUnicastIpAddressEntry.argtypes = [
ctypes.c_void_p, # Row : MIB_UNICASTIPADDRESS_ROW* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('IPHLPAPI.dll')
GetUnicastIpAddressEntry = Fiddle::Function.new(
lib['GetUnicastIpAddressEntry'],
[
Fiddle::TYPE_VOIDP, # Row : MIB_UNICASTIPADDRESS_ROW* in/out
],
-Fiddle::TYPE_INT)#[link(name = "iphlpapi")]
extern "system" {
fn GetUnicastIpAddressEntry(
Row: *mut MIB_UNICASTIPADDRESS_ROW // MIB_UNICASTIPADDRESS_ROW* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("IPHLPAPI.dll")]
public static extern uint GetUnicastIpAddressEntry(IntPtr Row);
"@
$api = Add-Type -MemberDefinition $sig -Name 'IPHLPAPI_GetUnicastIpAddressEntry' -Namespace Win32 -PassThru
# $api::GetUnicastIpAddressEntry(Row)#uselib "IPHLPAPI.dll"
#func global GetUnicastIpAddressEntry "GetUnicastIpAddressEntry" sptr
; GetUnicastIpAddressEntry varptr(Row) ; 戻り値は stat
; Row : MIB_UNICASTIPADDRESS_ROW* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "IPHLPAPI.dll" #cfunc global GetUnicastIpAddressEntry "GetUnicastIpAddressEntry" var ; res = GetUnicastIpAddressEntry(Row) ; Row : MIB_UNICASTIPADDRESS_ROW* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "IPHLPAPI.dll" #cfunc global GetUnicastIpAddressEntry "GetUnicastIpAddressEntry" sptr ; res = GetUnicastIpAddressEntry(varptr(Row)) ; Row : MIB_UNICASTIPADDRESS_ROW* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; WIN32_ERROR GetUnicastIpAddressEntry(MIB_UNICASTIPADDRESS_ROW* Row) #uselib "IPHLPAPI.dll" #cfunc global GetUnicastIpAddressEntry "GetUnicastIpAddressEntry" var ; res = GetUnicastIpAddressEntry(Row) ; Row : MIB_UNICASTIPADDRESS_ROW* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WIN32_ERROR GetUnicastIpAddressEntry(MIB_UNICASTIPADDRESS_ROW* Row) #uselib "IPHLPAPI.dll" #cfunc global GetUnicastIpAddressEntry "GetUnicastIpAddressEntry" intptr ; res = GetUnicastIpAddressEntry(varptr(Row)) ; Row : MIB_UNICASTIPADDRESS_ROW* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
procGetUnicastIpAddressEntry = iphlpapi.NewProc("GetUnicastIpAddressEntry")
)
// Row (MIB_UNICASTIPADDRESS_ROW* in/out)
r1, _, err := procGetUnicastIpAddressEntry.Call(
uintptr(Row),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction GetUnicastIpAddressEntry(
Row: Pointer // MIB_UNICASTIPADDRESS_ROW* in/out
): DWORD; stdcall;
external 'IPHLPAPI.dll' name 'GetUnicastIpAddressEntry';result := DllCall("IPHLPAPI\GetUnicastIpAddressEntry"
, "Ptr", Row ; MIB_UNICASTIPADDRESS_ROW* in/out
, "UInt") ; return: WIN32_ERROR●GetUnicastIpAddressEntry(Row) = DLL("IPHLPAPI.dll", "dword GetUnicastIpAddressEntry(void*)")
# 呼び出し: GetUnicastIpAddressEntry(Row)
# Row : MIB_UNICASTIPADDRESS_ROW* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "iphlpapi" fn GetUnicastIpAddressEntry(
Row: [*c]MIB_UNICASTIPADDRESS_ROW // MIB_UNICASTIPADDRESS_ROW* in/out
) callconv(std.os.windows.WINAPI) u32;proc GetUnicastIpAddressEntry(
Row: ptr MIB_UNICASTIPADDRESS_ROW # MIB_UNICASTIPADDRESS_ROW* in/out
): uint32 {.importc: "GetUnicastIpAddressEntry", stdcall, dynlib: "IPHLPAPI.dll".}pragma(lib, "iphlpapi");
extern(Windows)
uint GetUnicastIpAddressEntry(
MIB_UNICASTIPADDRESS_ROW* Row // MIB_UNICASTIPADDRESS_ROW* in/out
);ccall((:GetUnicastIpAddressEntry, "IPHLPAPI.dll"), stdcall, UInt32,
(Ptr{MIB_UNICASTIPADDRESS_ROW},),
Row)
# Row : MIB_UNICASTIPADDRESS_ROW* in/out -> Ptr{MIB_UNICASTIPADDRESS_ROW}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t GetUnicastIpAddressEntry(
void* Row);
]]
local iphlpapi = ffi.load("iphlpapi")
-- iphlpapi.GetUnicastIpAddressEntry(Row)
-- Row : MIB_UNICASTIPADDRESS_ROW* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('IPHLPAPI.dll');
const GetUnicastIpAddressEntry = lib.func('__stdcall', 'GetUnicastIpAddressEntry', 'uint32_t', ['void *']);
// GetUnicastIpAddressEntry(Row)
// Row : MIB_UNICASTIPADDRESS_ROW* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("IPHLPAPI.dll", {
GetUnicastIpAddressEntry: { parameters: ["pointer"], result: "u32" },
});
// lib.symbols.GetUnicastIpAddressEntry(Row)
// Row : MIB_UNICASTIPADDRESS_ROW* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t GetUnicastIpAddressEntry(
void* Row);
C, "IPHLPAPI.dll");
// $ffi->GetUnicastIpAddressEntry(Row);
// Row : MIB_UNICASTIPADDRESS_ROW* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Iphlpapi extends StdCallLibrary {
Iphlpapi INSTANCE = Native.load("iphlpapi", Iphlpapi.class);
int GetUnicastIpAddressEntry(
Pointer Row // MIB_UNICASTIPADDRESS_ROW* in/out
);
}@[Link("iphlpapi")]
lib LibIPHLPAPI
fun GetUnicastIpAddressEntry = GetUnicastIpAddressEntry(
Row : MIB_UNICASTIPADDRESS_ROW* # MIB_UNICASTIPADDRESS_ROW* in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetUnicastIpAddressEntryNative = Uint32 Function(Pointer<Void>);
typedef GetUnicastIpAddressEntryDart = int Function(Pointer<Void>);
final GetUnicastIpAddressEntry = DynamicLibrary.open('IPHLPAPI.dll')
.lookupFunction<GetUnicastIpAddressEntryNative, GetUnicastIpAddressEntryDart>('GetUnicastIpAddressEntry');
// Row : MIB_UNICASTIPADDRESS_ROW* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetUnicastIpAddressEntry(
Row: Pointer // MIB_UNICASTIPADDRESS_ROW* in/out
): DWORD; stdcall;
external 'IPHLPAPI.dll' name 'GetUnicastIpAddressEntry';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetUnicastIpAddressEntry"
c_GetUnicastIpAddressEntry :: Ptr () -> IO Word32
-- Row : MIB_UNICASTIPADDRESS_ROW* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getunicastipaddressentry =
foreign "GetUnicastIpAddressEntry"
((ptr void) @-> returning uint32_t)
(* Row : MIB_UNICASTIPADDRESS_ROW* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library iphlpapi (t "IPHLPAPI.dll"))
(cffi:use-foreign-library iphlpapi)
(cffi:defcfun ("GetUnicastIpAddressEntry" get-unicast-ip-address-entry :convention :stdcall) :uint32
(row :pointer)) ; MIB_UNICASTIPADDRESS_ROW* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetUnicastIpAddressEntry = Win32::API::More->new('IPHLPAPI',
'DWORD GetUnicastIpAddressEntry(LPVOID Row)');
# my $ret = $GetUnicastIpAddressEntry->Call($Row);
# Row : MIB_UNICASTIPADDRESS_ROW* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f CreateUnicastIpAddressEntry — インターフェイスに新しいユニキャストIPアドレスを追加する。
- f DeleteUnicastIpAddressEntry — 指定したユニキャストIPアドレスエントリを削除する。
- f GetUnicastIpAddressTable — ユニキャストIPアドレスの一覧テーブルを取得する。
- f InitializeUnicastIpAddressEntry — ユニキャストIPアドレス行構造体を既定値で初期化する。
- s MIB_UNICASTIPADDRESS_TABLE
- f NotifyUnicastIpAddressChange — ユニキャストIPアドレスの変更を通知登録する。
- f SetUnicastIpAddressEntry — 指定したユニキャストIPアドレスエントリを設定する。