ホーム › NetworkManagement.Dhcp › DhcpRemoveOptionV6
DhcpRemoveOptionV6
関数クラス/ベンダー指定でIPv6向けDHCPオプション定義を削除する。
シグネチャ
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpRemoveOptionV6(
LPWSTR ServerIpAddress, // optional
DWORD Flags,
DWORD OptionID,
LPWSTR ClassName, // optional
LPWSTR VendorName // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ServerIpAddress | LPWSTR | inoptional | 対象DHCPv6サーバーのIPアドレスを示すUnicode文字列。ローカルならNULL可。 |
| Flags | DWORD | in | ベンダー固有か否かを示すフラグ(DHCP_FLAGS_OPTION_IS_VENDOR等)。 |
| OptionID | DWORD | in | 削除するオプションの識別子(コード)。 |
| ClassName | LPWSTR | inoptional | オプションが属するクラス名。既定クラスならNULL可。 |
| VendorName | LPWSTR | inoptional | ベンダー固有オプションの場合のベンダー名。標準ならNULL可。 |
戻り値の型: DWORD
各言語での呼び出し定義
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpRemoveOptionV6(
LPWSTR ServerIpAddress, // optional
DWORD Flags,
DWORD OptionID,
LPWSTR ClassName, // optional
LPWSTR VendorName // optional
);[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpRemoveOptionV6(
[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 DhcpRemoveOptionV6(
<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 DhcpRemoveOptionV6 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
DhcpRemoveOptionV6 = ctypes.windll.dhcpsapi.DhcpRemoveOptionV6
DhcpRemoveOptionV6.restype = wintypes.DWORD
DhcpRemoveOptionV6.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')
DhcpRemoveOptionV6 = Fiddle::Function.new(
lib['DhcpRemoveOptionV6'],
[
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 DhcpRemoveOptionV6(
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 DhcpRemoveOptionV6([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_DhcpRemoveOptionV6' -Namespace Win32 -PassThru
# $api::DhcpRemoveOptionV6(ServerIpAddress, Flags, OptionID, ClassName, VendorName)#uselib "DHCPSAPI.dll"
#func global DhcpRemoveOptionV6 "DhcpRemoveOptionV6" sptr, sptr, sptr, sptr, sptr
; DhcpRemoveOptionV6 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 DhcpRemoveOptionV6 "DhcpRemoveOptionV6" wstr, int, int, wstr, wstr
; res = DhcpRemoveOptionV6(ServerIpAddress, Flags, OptionID, ClassName, VendorName)
; ServerIpAddress : LPWSTR optional -> "wstr"
; Flags : DWORD -> "int"
; OptionID : DWORD -> "int"
; ClassName : LPWSTR optional -> "wstr"
; VendorName : LPWSTR optional -> "wstr"; DWORD DhcpRemoveOptionV6(LPWSTR ServerIpAddress, DWORD Flags, DWORD OptionID, LPWSTR ClassName, LPWSTR VendorName)
#uselib "DHCPSAPI.dll"
#cfunc global DhcpRemoveOptionV6 "DhcpRemoveOptionV6" wstr, int, int, wstr, wstr
; res = DhcpRemoveOptionV6(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")
procDhcpRemoveOptionV6 = dhcpsapi.NewProc("DhcpRemoveOptionV6")
)
// ServerIpAddress (LPWSTR optional), Flags (DWORD), OptionID (DWORD), ClassName (LPWSTR optional), VendorName (LPWSTR optional)
r1, _, err := procDhcpRemoveOptionV6.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 // DWORDfunction DhcpRemoveOptionV6(
ServerIpAddress: PWideChar; // LPWSTR optional
Flags: DWORD; // DWORD
OptionID: DWORD; // DWORD
ClassName: PWideChar; // LPWSTR optional
VendorName: PWideChar // LPWSTR optional
): DWORD; stdcall;
external 'DHCPSAPI.dll' name 'DhcpRemoveOptionV6';result := DllCall("DHCPSAPI\DhcpRemoveOptionV6"
, "WStr", ServerIpAddress ; LPWSTR optional
, "UInt", Flags ; DWORD
, "UInt", OptionID ; DWORD
, "WStr", ClassName ; LPWSTR optional
, "WStr", VendorName ; LPWSTR optional
, "UInt") ; return: DWORD●DhcpRemoveOptionV6(ServerIpAddress, Flags, OptionID, ClassName, VendorName) = DLL("DHCPSAPI.dll", "dword DhcpRemoveOptionV6(char*, dword, dword, char*, char*)")
# 呼び出し: DhcpRemoveOptionV6(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)。const std = @import("std");
extern "dhcpsapi" fn DhcpRemoveOptionV6(
ServerIpAddress: [*c]const u16, // LPWSTR optional
Flags: u32, // DWORD
OptionID: u32, // DWORD
ClassName: [*c]const u16, // LPWSTR optional
VendorName: [*c]const u16 // LPWSTR optional
) callconv(std.os.windows.WINAPI) u32;proc DhcpRemoveOptionV6(
ServerIpAddress: WideCString, # LPWSTR optional
Flags: uint32, # DWORD
OptionID: uint32, # DWORD
ClassName: WideCString, # LPWSTR optional
VendorName: WideCString # LPWSTR optional
): uint32 {.importc: "DhcpRemoveOptionV6", stdcall, dynlib: "DHCPSAPI.dll".}pragma(lib, "dhcpsapi");
extern(Windows)
uint DhcpRemoveOptionV6(
const(wchar)* ServerIpAddress, // LPWSTR optional
uint Flags, // DWORD
uint OptionID, // DWORD
const(wchar)* ClassName, // LPWSTR optional
const(wchar)* VendorName // LPWSTR optional
);ccall((:DhcpRemoveOptionV6, "DHCPSAPI.dll"), stdcall, UInt32,
(Cwstring, UInt32, UInt32, Cwstring, Cwstring),
ServerIpAddress, Flags, OptionID, ClassName, VendorName)
# ServerIpAddress : LPWSTR optional -> Cwstring
# Flags : DWORD -> UInt32
# OptionID : DWORD -> UInt32
# ClassName : LPWSTR optional -> Cwstring
# VendorName : LPWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t DhcpRemoveOptionV6(
const uint16_t* ServerIpAddress,
uint32_t Flags,
uint32_t OptionID,
const uint16_t* ClassName,
const uint16_t* VendorName);
]]
local dhcpsapi = ffi.load("dhcpsapi")
-- dhcpsapi.DhcpRemoveOptionV6(ServerIpAddress, Flags, OptionID, ClassName, VendorName)
-- ServerIpAddress : LPWSTR optional
-- Flags : DWORD
-- OptionID : DWORD
-- ClassName : LPWSTR optional
-- VendorName : LPWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('DHCPSAPI.dll');
const DhcpRemoveOptionV6 = lib.func('__stdcall', 'DhcpRemoveOptionV6', 'uint32_t', ['str16', 'uint32_t', 'uint32_t', 'str16', 'str16']);
// DhcpRemoveOptionV6(ServerIpAddress, Flags, OptionID, ClassName, VendorName)
// ServerIpAddress : LPWSTR optional -> 'str16'
// Flags : DWORD -> 'uint32_t'
// OptionID : DWORD -> 'uint32_t'
// ClassName : LPWSTR optional -> 'str16'
// VendorName : LPWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("DHCPSAPI.dll", {
DhcpRemoveOptionV6: { parameters: ["buffer", "u32", "u32", "buffer", "buffer"], result: "u32" },
});
// lib.symbols.DhcpRemoveOptionV6(ServerIpAddress, Flags, OptionID, ClassName, VendorName)
// ServerIpAddress : LPWSTR optional -> "buffer"
// Flags : DWORD -> "u32"
// OptionID : DWORD -> "u32"
// ClassName : LPWSTR optional -> "buffer"
// VendorName : LPWSTR optional -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t DhcpRemoveOptionV6(
const uint16_t* ServerIpAddress,
uint32_t Flags,
uint32_t OptionID,
const uint16_t* ClassName,
const uint16_t* VendorName);
C, "DHCPSAPI.dll");
// $ffi->DhcpRemoveOptionV6(ServerIpAddress, Flags, OptionID, ClassName, VendorName);
// ServerIpAddress : LPWSTR optional
// Flags : DWORD
// OptionID : DWORD
// ClassName : LPWSTR optional
// VendorName : LPWSTR optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Dhcpsapi extends StdCallLibrary {
Dhcpsapi INSTANCE = Native.load("dhcpsapi", Dhcpsapi.class);
int DhcpRemoveOptionV6(
WString ServerIpAddress, // LPWSTR optional
int Flags, // DWORD
int OptionID, // DWORD
WString ClassName, // LPWSTR optional
WString VendorName // LPWSTR optional
);
}@[Link("dhcpsapi")]
lib LibDHCPSAPI
fun DhcpRemoveOptionV6 = DhcpRemoveOptionV6(
ServerIpAddress : UInt16*, # LPWSTR optional
Flags : UInt32, # DWORD
OptionID : UInt32, # DWORD
ClassName : UInt16*, # LPWSTR optional
VendorName : UInt16* # LPWSTR optional
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DhcpRemoveOptionV6Native = Uint32 Function(Pointer<Utf16>, Uint32, Uint32, Pointer<Utf16>, Pointer<Utf16>);
typedef DhcpRemoveOptionV6Dart = int Function(Pointer<Utf16>, int, int, Pointer<Utf16>, Pointer<Utf16>);
final DhcpRemoveOptionV6 = DynamicLibrary.open('DHCPSAPI.dll')
.lookupFunction<DhcpRemoveOptionV6Native, DhcpRemoveOptionV6Dart>('DhcpRemoveOptionV6');
// ServerIpAddress : LPWSTR optional -> Pointer<Utf16>
// Flags : DWORD -> Uint32
// OptionID : DWORD -> Uint32
// ClassName : LPWSTR optional -> Pointer<Utf16>
// VendorName : LPWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DhcpRemoveOptionV6(
ServerIpAddress: PWideChar; // LPWSTR optional
Flags: DWORD; // DWORD
OptionID: DWORD; // DWORD
ClassName: PWideChar; // LPWSTR optional
VendorName: PWideChar // LPWSTR optional
): DWORD; stdcall;
external 'DHCPSAPI.dll' name 'DhcpRemoveOptionV6';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DhcpRemoveOptionV6"
c_DhcpRemoveOptionV6 :: CWString -> Word32 -> Word32 -> CWString -> CWString -> IO Word32
-- ServerIpAddress : LPWSTR optional -> CWString
-- Flags : DWORD -> Word32
-- OptionID : DWORD -> Word32
-- ClassName : LPWSTR optional -> CWString
-- VendorName : LPWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dhcpremoveoptionv6 =
foreign "DhcpRemoveOptionV6"
((ptr uint16_t) @-> uint32_t @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning uint32_t)
(* ServerIpAddress : LPWSTR optional -> (ptr uint16_t) *)
(* Flags : DWORD -> uint32_t *)
(* OptionID : DWORD -> uint32_t *)
(* ClassName : LPWSTR optional -> (ptr uint16_t) *)
(* VendorName : LPWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library dhcpsapi (t "DHCPSAPI.dll"))
(cffi:use-foreign-library dhcpsapi)
(cffi:defcfun ("DhcpRemoveOptionV6" dhcp-remove-option-v6 :convention :stdcall) :uint32
(server-ip-address (:string :encoding :utf-16le)) ; LPWSTR optional
(flags :uint32) ; DWORD
(option-id :uint32) ; DWORD
(class-name (:string :encoding :utf-16le)) ; LPWSTR optional
(vendor-name (:string :encoding :utf-16le))) ; LPWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DhcpRemoveOptionV6 = Win32::API::More->new('DHCPSAPI',
'DWORD DhcpRemoveOptionV6(LPCWSTR ServerIpAddress, DWORD Flags, DWORD OptionID, LPCWSTR ClassName, LPCWSTR VendorName)');
# my $ret = $DhcpRemoveOptionV6->Call($ServerIpAddress, $Flags, $OptionID, $ClassName, $VendorName);
# ServerIpAddress : LPWSTR optional -> LPCWSTR
# Flags : DWORD -> DWORD
# OptionID : DWORD -> DWORD
# ClassName : LPWSTR optional -> LPCWSTR
# VendorName : LPWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f DhcpRemoveOptionV5 — クラス/ベンダー指定でDHCPオプション定義を削除する。