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

DhcpRemoveOptionV5

関数
クラス/ベンダー指定でDHCPオプション定義を削除する。
DLLDHCPSAPI.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

DWORD DhcpRemoveOptionV5(
    LPWSTR ServerIpAddress,   // optional
    DWORD Flags,
    DWORD OptionID,
    LPWSTR ClassName,   // optional
    LPWSTR VendorName   // optional
);

パラメーター

名前方向
ServerIpAddressLPWSTRinoptional
FlagsDWORDin
OptionIDDWORDin
ClassNameLPWSTRinoptional
VendorNameLPWSTRinoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

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

DhcpRemoveOptionV5 = ctypes.windll.dhcpsapi.DhcpRemoveOptionV5
DhcpRemoveOptionV5.restype = wintypes.DWORD
DhcpRemoveOptionV5.argtypes = [
    wintypes.LPCWSTR,  # ServerIpAddress : LPWSTR optional
    wintypes.DWORD,  # Flags : DWORD
    wintypes.DWORD,  # OptionID : DWORD
    wintypes.LPCWSTR,  # ClassName : LPWSTR optional
    wintypes.LPCWSTR,  # VendorName : LPWSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpRemoveOptionV5 = Fiddle::Function.new(
  lib['DhcpRemoveOptionV5'],
  [
    Fiddle::TYPE_VOIDP,  # ServerIpAddress : LPWSTR optional
    -Fiddle::TYPE_INT,  # Flags : DWORD
    -Fiddle::TYPE_INT,  # OptionID : DWORD
    Fiddle::TYPE_VOIDP,  # ClassName : LPWSTR optional
    Fiddle::TYPE_VOIDP,  # VendorName : LPWSTR optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "dhcpsapi")]
extern "system" {
    fn DhcpRemoveOptionV5(
        ServerIpAddress: *mut u16,  // LPWSTR optional
        Flags: u32,  // DWORD
        OptionID: u32,  // DWORD
        ClassName: *mut u16,  // LPWSTR optional
        VendorName: *mut u16  // LPWSTR optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("DHCPSAPI.dll")]
public static extern uint DhcpRemoveOptionV5([MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, uint Flags, uint OptionID, [MarshalAs(UnmanagedType.LPWStr)] string ClassName, [MarshalAs(UnmanagedType.LPWStr)] string VendorName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpRemoveOptionV5' -Namespace Win32 -PassThru
# $api::DhcpRemoveOptionV5(ServerIpAddress, Flags, OptionID, ClassName, VendorName)
#uselib "DHCPSAPI.dll"
#func global DhcpRemoveOptionV5 "DhcpRemoveOptionV5" sptr, sptr, sptr, sptr, sptr
; DhcpRemoveOptionV5 ServerIpAddress, Flags, OptionID, ClassName, VendorName   ; 戻り値は stat
; ServerIpAddress : LPWSTR optional -> "sptr"
; Flags : DWORD -> "sptr"
; OptionID : DWORD -> "sptr"
; ClassName : LPWSTR optional -> "sptr"
; VendorName : LPWSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "DHCPSAPI.dll"
#cfunc global DhcpRemoveOptionV5 "DhcpRemoveOptionV5" wstr, int, int, wstr, wstr
; res = DhcpRemoveOptionV5(ServerIpAddress, Flags, OptionID, ClassName, VendorName)
; ServerIpAddress : LPWSTR optional -> "wstr"
; Flags : DWORD -> "int"
; OptionID : DWORD -> "int"
; ClassName : LPWSTR optional -> "wstr"
; VendorName : LPWSTR optional -> "wstr"
; DWORD DhcpRemoveOptionV5(LPWSTR ServerIpAddress, DWORD Flags, DWORD OptionID, LPWSTR ClassName, LPWSTR VendorName)
#uselib "DHCPSAPI.dll"
#cfunc global DhcpRemoveOptionV5 "DhcpRemoveOptionV5" wstr, int, int, wstr, wstr
; res = DhcpRemoveOptionV5(ServerIpAddress, Flags, OptionID, ClassName, VendorName)
; ServerIpAddress : LPWSTR optional -> "wstr"
; Flags : DWORD -> "int"
; OptionID : DWORD -> "int"
; ClassName : LPWSTR optional -> "wstr"
; VendorName : LPWSTR optional -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpRemoveOptionV5 = dhcpsapi.NewProc("DhcpRemoveOptionV5")
)

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