ホーム › NetworkManagement.Dhcp › DhcpGetMibInfoV6
DhcpGetMibInfoV6
関数DHCPサーバーのIPv6スコープに関するMIB統計情報を取得する。
シグネチャ
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpGetMibInfoV6(
LPCWSTR ServerIpAddress, // optional
DHCP_MIB_INFO_V6** MibInfo
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ServerIpAddress | LPCWSTR | inoptional | 対象DHCPv6サーバーのIPアドレスを示すUnicode文字列。ローカルならNULL可。 |
| MibInfo | DHCP_MIB_INFO_V6** | inout | 取得したIPv6統計(MIB)情報のDHCP_MIB_INFO_V6へのポインタを受け取る二重ポインタ。使用後は解放する。 |
戻り値の型: DWORD
各言語での呼び出し定義
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpGetMibInfoV6(
LPCWSTR ServerIpAddress, // optional
DHCP_MIB_INFO_V6** MibInfo
);[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpGetMibInfoV6(
[MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, // LPCWSTR optional
IntPtr MibInfo // DHCP_MIB_INFO_V6** in/out
);<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpGetMibInfoV6(
<MarshalAs(UnmanagedType.LPWStr)> ServerIpAddress As String, ' LPCWSTR optional
MibInfo As IntPtr ' DHCP_MIB_INFO_V6** in/out
) As UInteger
End Function' ServerIpAddress : LPCWSTR optional
' MibInfo : DHCP_MIB_INFO_V6** in/out
Declare PtrSafe Function DhcpGetMibInfoV6 Lib "dhcpsapi" ( _
ByVal ServerIpAddress As LongPtr, _
ByVal MibInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DhcpGetMibInfoV6 = ctypes.windll.dhcpsapi.DhcpGetMibInfoV6
DhcpGetMibInfoV6.restype = wintypes.DWORD
DhcpGetMibInfoV6.argtypes = [
wintypes.LPCWSTR, # ServerIpAddress : LPCWSTR optional
ctypes.c_void_p, # MibInfo : DHCP_MIB_INFO_V6** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpGetMibInfoV6 = Fiddle::Function.new(
lib['DhcpGetMibInfoV6'],
[
Fiddle::TYPE_VOIDP, # ServerIpAddress : LPCWSTR optional
Fiddle::TYPE_VOIDP, # MibInfo : DHCP_MIB_INFO_V6** in/out
],
-Fiddle::TYPE_INT)#[link(name = "dhcpsapi")]
extern "system" {
fn DhcpGetMibInfoV6(
ServerIpAddress: *const u16, // LPCWSTR optional
MibInfo: *mut *mut DHCP_MIB_INFO_V6 // DHCP_MIB_INFO_V6** in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("DHCPSAPI.dll")]
public static extern uint DhcpGetMibInfoV6([MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, IntPtr MibInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpGetMibInfoV6' -Namespace Win32 -PassThru
# $api::DhcpGetMibInfoV6(ServerIpAddress, MibInfo)#uselib "DHCPSAPI.dll"
#func global DhcpGetMibInfoV6 "DhcpGetMibInfoV6" sptr, sptr
; DhcpGetMibInfoV6 ServerIpAddress, varptr(MibInfo) ; 戻り値は stat
; ServerIpAddress : LPCWSTR optional -> "sptr"
; MibInfo : DHCP_MIB_INFO_V6** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "DHCPSAPI.dll" #cfunc global DhcpGetMibInfoV6 "DhcpGetMibInfoV6" wstr, var ; res = DhcpGetMibInfoV6(ServerIpAddress, MibInfo) ; ServerIpAddress : LPCWSTR optional -> "wstr" ; MibInfo : DHCP_MIB_INFO_V6** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "DHCPSAPI.dll" #cfunc global DhcpGetMibInfoV6 "DhcpGetMibInfoV6" wstr, sptr ; res = DhcpGetMibInfoV6(ServerIpAddress, varptr(MibInfo)) ; ServerIpAddress : LPCWSTR optional -> "wstr" ; MibInfo : DHCP_MIB_INFO_V6** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD DhcpGetMibInfoV6(LPCWSTR ServerIpAddress, DHCP_MIB_INFO_V6** MibInfo) #uselib "DHCPSAPI.dll" #cfunc global DhcpGetMibInfoV6 "DhcpGetMibInfoV6" wstr, var ; res = DhcpGetMibInfoV6(ServerIpAddress, MibInfo) ; ServerIpAddress : LPCWSTR optional -> "wstr" ; MibInfo : DHCP_MIB_INFO_V6** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD DhcpGetMibInfoV6(LPCWSTR ServerIpAddress, DHCP_MIB_INFO_V6** MibInfo) #uselib "DHCPSAPI.dll" #cfunc global DhcpGetMibInfoV6 "DhcpGetMibInfoV6" wstr, intptr ; res = DhcpGetMibInfoV6(ServerIpAddress, varptr(MibInfo)) ; ServerIpAddress : LPCWSTR optional -> "wstr" ; MibInfo : DHCP_MIB_INFO_V6** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
procDhcpGetMibInfoV6 = dhcpsapi.NewProc("DhcpGetMibInfoV6")
)
// ServerIpAddress (LPCWSTR optional), MibInfo (DHCP_MIB_INFO_V6** in/out)
r1, _, err := procDhcpGetMibInfoV6.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerIpAddress))),
uintptr(MibInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction DhcpGetMibInfoV6(
ServerIpAddress: PWideChar; // LPCWSTR optional
MibInfo: Pointer // DHCP_MIB_INFO_V6** in/out
): DWORD; stdcall;
external 'DHCPSAPI.dll' name 'DhcpGetMibInfoV6';result := DllCall("DHCPSAPI\DhcpGetMibInfoV6"
, "WStr", ServerIpAddress ; LPCWSTR optional
, "Ptr", MibInfo ; DHCP_MIB_INFO_V6** in/out
, "UInt") ; return: DWORD●DhcpGetMibInfoV6(ServerIpAddress, MibInfo) = DLL("DHCPSAPI.dll", "dword DhcpGetMibInfoV6(char*, void*)")
# 呼び出し: DhcpGetMibInfoV6(ServerIpAddress, MibInfo)
# ServerIpAddress : LPCWSTR optional -> "char*"
# MibInfo : DHCP_MIB_INFO_V6** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。