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

DhcpServerGetConfigV4

関数
DHCPサーバーのV4拡張の構成パラメータを取得する。
DLLDHCPSAPI.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

DWORD DhcpServerGetConfigV4(
    LPCWSTR ServerIpAddress,   // optional
    DHCP_SERVER_CONFIG_INFO_V4** ConfigInfo
);

パラメーター

名前方向
ServerIpAddressLPCWSTRinoptional
ConfigInfoDHCP_SERVER_CONFIG_INFO_V4**inout

戻り値の型: DWORD

各言語での呼び出し定義

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

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

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

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

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpServerGetConfigV4 = dhcpsapi.NewProc("DhcpServerGetConfigV4")
)

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