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