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