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