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