ホーム › NetworkManagement.Dhcp › DhcpV4FailoverGetScopeStatistics
DhcpV4FailoverGetScopeStatistics
関数指定スコープのIPv4フェールオーバー統計情報を取得する。
シグネチャ
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpV4FailoverGetScopeStatistics(
LPWSTR ServerIpAddress, // optional
DWORD ScopeId,
DHCP_FAILOVER_STATISTICS** pStats
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ServerIpAddress | LPWSTR | inoptional | 対象DHCPサーバーのIPアドレスを示すUnicode文字列。ローカルならNULL可。 |
| ScopeId | DWORD | in | 統計を取得する対象スコープのID(サブネットアドレスDWORD)。 |
| pStats | DHCP_FAILOVER_STATISTICS** | out | 取得したフェールオーバー統計のDHCP_FAILOVER_STATISTICSへのポインタを受け取る二重ポインタ。使用後は解放する。 |
戻り値の型: 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)。const std = @import("std");
extern "dhcpsapi" fn DhcpV4FailoverGetScopeStatistics(
ServerIpAddress: [*c]const u16, // LPWSTR optional
ScopeId: u32, // DWORD
pStats: [*c][*c]DHCP_FAILOVER_STATISTICS // DHCP_FAILOVER_STATISTICS** out
) callconv(std.os.windows.WINAPI) u32;proc DhcpV4FailoverGetScopeStatistics(
ServerIpAddress: WideCString, # LPWSTR optional
ScopeId: uint32, # DWORD
pStats: ptr DHCP_FAILOVER_STATISTICS # DHCP_FAILOVER_STATISTICS** out
): uint32 {.importc: "DhcpV4FailoverGetScopeStatistics", stdcall, dynlib: "DHCPSAPI.dll".}pragma(lib, "dhcpsapi");
extern(Windows)
uint DhcpV4FailoverGetScopeStatistics(
const(wchar)* ServerIpAddress, // LPWSTR optional
uint ScopeId, // DWORD
DHCP_FAILOVER_STATISTICS** pStats // DHCP_FAILOVER_STATISTICS** out
);ccall((:DhcpV4FailoverGetScopeStatistics, "DHCPSAPI.dll"), stdcall, UInt32,
(Cwstring, UInt32, Ptr{DHCP_FAILOVER_STATISTICS}),
ServerIpAddress, ScopeId, pStats)
# ServerIpAddress : LPWSTR optional -> Cwstring
# ScopeId : DWORD -> UInt32
# pStats : DHCP_FAILOVER_STATISTICS** out -> Ptr{DHCP_FAILOVER_STATISTICS}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t DhcpV4FailoverGetScopeStatistics(
const uint16_t* ServerIpAddress,
uint32_t ScopeId,
void* pStats);
]]
local dhcpsapi = ffi.load("dhcpsapi")
-- dhcpsapi.DhcpV4FailoverGetScopeStatistics(ServerIpAddress, ScopeId, pStats)
-- ServerIpAddress : LPWSTR optional
-- ScopeId : DWORD
-- pStats : DHCP_FAILOVER_STATISTICS** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('DHCPSAPI.dll');
const DhcpV4FailoverGetScopeStatistics = lib.func('__stdcall', 'DhcpV4FailoverGetScopeStatistics', 'uint32_t', ['str16', 'uint32_t', 'void *']);
// DhcpV4FailoverGetScopeStatistics(ServerIpAddress, ScopeId, pStats)
// ServerIpAddress : LPWSTR optional -> 'str16'
// ScopeId : DWORD -> 'uint32_t'
// pStats : DHCP_FAILOVER_STATISTICS** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("DHCPSAPI.dll", {
DhcpV4FailoverGetScopeStatistics: { parameters: ["buffer", "u32", "pointer"], result: "u32" },
});
// lib.symbols.DhcpV4FailoverGetScopeStatistics(ServerIpAddress, ScopeId, pStats)
// ServerIpAddress : LPWSTR optional -> "buffer"
// ScopeId : DWORD -> "u32"
// pStats : DHCP_FAILOVER_STATISTICS** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t DhcpV4FailoverGetScopeStatistics(
const uint16_t* ServerIpAddress,
uint32_t ScopeId,
void* pStats);
C, "DHCPSAPI.dll");
// $ffi->DhcpV4FailoverGetScopeStatistics(ServerIpAddress, ScopeId, pStats);
// ServerIpAddress : LPWSTR optional
// ScopeId : DWORD
// pStats : DHCP_FAILOVER_STATISTICS** 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 Dhcpsapi extends StdCallLibrary {
Dhcpsapi INSTANCE = Native.load("dhcpsapi", Dhcpsapi.class);
int DhcpV4FailoverGetScopeStatistics(
WString ServerIpAddress, // LPWSTR optional
int ScopeId, // DWORD
Pointer pStats // DHCP_FAILOVER_STATISTICS** out
);
}@[Link("dhcpsapi")]
lib LibDHCPSAPI
fun DhcpV4FailoverGetScopeStatistics = DhcpV4FailoverGetScopeStatistics(
ServerIpAddress : UInt16*, # LPWSTR optional
ScopeId : UInt32, # DWORD
pStats : DHCP_FAILOVER_STATISTICS** # DHCP_FAILOVER_STATISTICS** out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DhcpV4FailoverGetScopeStatisticsNative = Uint32 Function(Pointer<Utf16>, Uint32, Pointer<Void>);
typedef DhcpV4FailoverGetScopeStatisticsDart = int Function(Pointer<Utf16>, int, Pointer<Void>);
final DhcpV4FailoverGetScopeStatistics = DynamicLibrary.open('DHCPSAPI.dll')
.lookupFunction<DhcpV4FailoverGetScopeStatisticsNative, DhcpV4FailoverGetScopeStatisticsDart>('DhcpV4FailoverGetScopeStatistics');
// ServerIpAddress : LPWSTR optional -> Pointer<Utf16>
// ScopeId : DWORD -> Uint32
// pStats : DHCP_FAILOVER_STATISTICS** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DhcpV4FailoverGetScopeStatistics(
ServerIpAddress: PWideChar; // LPWSTR optional
ScopeId: DWORD; // DWORD
pStats: Pointer // DHCP_FAILOVER_STATISTICS** out
): DWORD; stdcall;
external 'DHCPSAPI.dll' name 'DhcpV4FailoverGetScopeStatistics';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DhcpV4FailoverGetScopeStatistics"
c_DhcpV4FailoverGetScopeStatistics :: CWString -> Word32 -> Ptr () -> IO Word32
-- ServerIpAddress : LPWSTR optional -> CWString
-- ScopeId : DWORD -> Word32
-- pStats : DHCP_FAILOVER_STATISTICS** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dhcpv4failovergetscopestatistics =
foreign "DhcpV4FailoverGetScopeStatistics"
((ptr uint16_t) @-> uint32_t @-> (ptr void) @-> returning uint32_t)
(* ServerIpAddress : LPWSTR optional -> (ptr uint16_t) *)
(* ScopeId : DWORD -> uint32_t *)
(* pStats : DHCP_FAILOVER_STATISTICS** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library dhcpsapi (t "DHCPSAPI.dll"))
(cffi:use-foreign-library dhcpsapi)
(cffi:defcfun ("DhcpV4FailoverGetScopeStatistics" dhcp-v4-failover-get-scope-statistics :convention :stdcall) :uint32
(server-ip-address (:string :encoding :utf-16le)) ; LPWSTR optional
(scope-id :uint32) ; DWORD
(p-stats :pointer)) ; DHCP_FAILOVER_STATISTICS** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DhcpV4FailoverGetScopeStatistics = Win32::API::More->new('DHCPSAPI',
'DWORD DhcpV4FailoverGetScopeStatistics(LPCWSTR ServerIpAddress, DWORD ScopeId, LPVOID pStats)');
# my $ret = $DhcpV4FailoverGetScopeStatistics->Call($ServerIpAddress, $ScopeId, $pStats);
# ServerIpAddress : LPWSTR optional -> LPCWSTR
# ScopeId : DWORD -> DWORD
# pStats : DHCP_FAILOVER_STATISTICS** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。