Win32 API 日本語リファレンス
ホームNetworkManagement.Dhcp › DhcpGetSuperScopeInfoV4

DhcpGetSuperScopeInfoV4

関数
DHCPサーバーのスーパースコープ構成情報を取得する。
DLLDHCPSAPI.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

// DHCPSAPI.dll
#include <windows.h>

DWORD DhcpGetSuperScopeInfoV4(
    LPCWSTR ServerIpAddress,   // optional
    DHCP_SUPER_SCOPE_TABLE** SuperScopeTable
);

パラメーター

名前方向説明
ServerIpAddressLPCWSTRinoptional操作対象DHCPサーバのIPアドレスまたはホスト名(Unicode)。
SuperScopeTableDHCP_SUPER_SCOPE_TABLE**inout取得したスーパースコープ一覧を受け取るDHCP_SUPER_SCOPE_TABLEへのポインタ。RPC割当てで要解放。

戻り値の型: DWORD

各言語での呼び出し定義

// DHCPSAPI.dll
#include <windows.h>

DWORD DhcpGetSuperScopeInfoV4(
    LPCWSTR ServerIpAddress,   // optional
    DHCP_SUPER_SCOPE_TABLE** SuperScopeTable
);
[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpGetSuperScopeInfoV4(
    [MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress,   // LPCWSTR optional
    IntPtr SuperScopeTable   // DHCP_SUPER_SCOPE_TABLE** in/out
);
<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpGetSuperScopeInfoV4(
    <MarshalAs(UnmanagedType.LPWStr)> ServerIpAddress As String,   ' LPCWSTR optional
    SuperScopeTable As IntPtr   ' DHCP_SUPER_SCOPE_TABLE** in/out
) As UInteger
End Function
' ServerIpAddress : LPCWSTR optional
' SuperScopeTable : DHCP_SUPER_SCOPE_TABLE** in/out
Declare PtrSafe Function DhcpGetSuperScopeInfoV4 Lib "dhcpsapi" ( _
    ByVal ServerIpAddress As LongPtr, _
    ByVal SuperScopeTable As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DhcpGetSuperScopeInfoV4 = ctypes.windll.dhcpsapi.DhcpGetSuperScopeInfoV4
DhcpGetSuperScopeInfoV4.restype = wintypes.DWORD
DhcpGetSuperScopeInfoV4.argtypes = [
    wintypes.LPCWSTR,  # ServerIpAddress : LPCWSTR optional
    ctypes.c_void_p,  # SuperScopeTable : DHCP_SUPER_SCOPE_TABLE** in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpGetSuperScopeInfoV4 = Fiddle::Function.new(
  lib['DhcpGetSuperScopeInfoV4'],
  [
    Fiddle::TYPE_VOIDP,  # ServerIpAddress : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # SuperScopeTable : DHCP_SUPER_SCOPE_TABLE** in/out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "dhcpsapi")]
extern "system" {
    fn DhcpGetSuperScopeInfoV4(
        ServerIpAddress: *const u16,  // LPCWSTR optional
        SuperScopeTable: *mut *mut DHCP_SUPER_SCOPE_TABLE  // DHCP_SUPER_SCOPE_TABLE** in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("DHCPSAPI.dll")]
public static extern uint DhcpGetSuperScopeInfoV4([MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, IntPtr SuperScopeTable);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpGetSuperScopeInfoV4' -Namespace Win32 -PassThru
# $api::DhcpGetSuperScopeInfoV4(ServerIpAddress, SuperScopeTable)
#uselib "DHCPSAPI.dll"
#func global DhcpGetSuperScopeInfoV4 "DhcpGetSuperScopeInfoV4" sptr, sptr
; DhcpGetSuperScopeInfoV4 ServerIpAddress, varptr(SuperScopeTable)   ; 戻り値は stat
; ServerIpAddress : LPCWSTR optional -> "sptr"
; SuperScopeTable : DHCP_SUPER_SCOPE_TABLE** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "DHCPSAPI.dll"
#cfunc global DhcpGetSuperScopeInfoV4 "DhcpGetSuperScopeInfoV4" wstr, var
; res = DhcpGetSuperScopeInfoV4(ServerIpAddress, SuperScopeTable)
; ServerIpAddress : LPCWSTR optional -> "wstr"
; SuperScopeTable : DHCP_SUPER_SCOPE_TABLE** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD DhcpGetSuperScopeInfoV4(LPCWSTR ServerIpAddress, DHCP_SUPER_SCOPE_TABLE** SuperScopeTable)
#uselib "DHCPSAPI.dll"
#cfunc global DhcpGetSuperScopeInfoV4 "DhcpGetSuperScopeInfoV4" wstr, var
; res = DhcpGetSuperScopeInfoV4(ServerIpAddress, SuperScopeTable)
; ServerIpAddress : LPCWSTR optional -> "wstr"
; SuperScopeTable : DHCP_SUPER_SCOPE_TABLE** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpGetSuperScopeInfoV4 = dhcpsapi.NewProc("DhcpGetSuperScopeInfoV4")
)

// ServerIpAddress (LPCWSTR optional), SuperScopeTable (DHCP_SUPER_SCOPE_TABLE** in/out)
r1, _, err := procDhcpGetSuperScopeInfoV4.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerIpAddress))),
	uintptr(SuperScopeTable),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function DhcpGetSuperScopeInfoV4(
  ServerIpAddress: PWideChar;   // LPCWSTR optional
  SuperScopeTable: Pointer   // DHCP_SUPER_SCOPE_TABLE** in/out
): DWORD; stdcall;
  external 'DHCPSAPI.dll' name 'DhcpGetSuperScopeInfoV4';
result := DllCall("DHCPSAPI\DhcpGetSuperScopeInfoV4"
    , "WStr", ServerIpAddress   ; LPCWSTR optional
    , "Ptr", SuperScopeTable   ; DHCP_SUPER_SCOPE_TABLE** in/out
    , "UInt")   ; return: DWORD
●DhcpGetSuperScopeInfoV4(ServerIpAddress, SuperScopeTable) = DLL("DHCPSAPI.dll", "dword DhcpGetSuperScopeInfoV4(char*, void*)")
# 呼び出し: DhcpGetSuperScopeInfoV4(ServerIpAddress, SuperScopeTable)
# ServerIpAddress : LPCWSTR optional -> "char*"
# SuperScopeTable : DHCP_SUPER_SCOPE_TABLE** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。