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