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

DhcpV4RemoveOptionValue

関数
指定スコープから特定のIPv4 DHCPオプション値を削除する。
DLLDHCPSAPI.dll呼出規約winapi対応OSwindowsserver2012

シグネチャ

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

DWORD DhcpV4RemoveOptionValue(
    LPWSTR ServerIpAddress,   // optional
    DWORD Flags,
    DWORD OptionID,
    LPWSTR PolicyName,   // optional
    LPWSTR VendorName,   // optional
    DHCP_OPTION_SCOPE_INFO* ScopeInfo
);

パラメーター

名前方向
ServerIpAddressLPWSTRinoptional
FlagsDWORDin
OptionIDDWORDin
PolicyNameLPWSTRinoptional
VendorNameLPWSTRinoptional
ScopeInfoDHCP_OPTION_SCOPE_INFO*inout

戻り値の型: DWORD

各言語での呼び出し定義

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

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

DhcpV4RemoveOptionValue = ctypes.windll.dhcpsapi.DhcpV4RemoveOptionValue
DhcpV4RemoveOptionValue.restype = wintypes.DWORD
DhcpV4RemoveOptionValue.argtypes = [
    wintypes.LPCWSTR,  # ServerIpAddress : LPWSTR optional
    wintypes.DWORD,  # Flags : DWORD
    wintypes.DWORD,  # OptionID : DWORD
    wintypes.LPCWSTR,  # PolicyName : LPWSTR optional
    wintypes.LPCWSTR,  # VendorName : LPWSTR optional
    ctypes.c_void_p,  # ScopeInfo : DHCP_OPTION_SCOPE_INFO* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpV4RemoveOptionValue = dhcpsapi.NewProc("DhcpV4RemoveOptionValue")
)

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