ホーム › NetworkManagement.Dhcp › DhcpRemoveOption
DhcpRemoveOption
関数DHCPサーバーから指定したオプション定義を削除する。
シグネチャ
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpRemoveOption(
LPCWSTR ServerIpAddress, // optional
DWORD OptionID
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ServerIpAddress | LPCWSTR | inoptional | 操作対象DHCPサーバのIPアドレスまたはホスト名(Unicode)。 |
| OptionID | DWORD | in | 削除するDHCPオプションのIDを指定する。 |
戻り値の型: DWORD
各言語での呼び出し定義
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpRemoveOption(
LPCWSTR ServerIpAddress, // optional
DWORD OptionID
);[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpRemoveOption(
[MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, // LPCWSTR optional
uint OptionID // DWORD
);<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpRemoveOption(
<MarshalAs(UnmanagedType.LPWStr)> ServerIpAddress As String, ' LPCWSTR optional
OptionID As UInteger ' DWORD
) As UInteger
End Function' ServerIpAddress : LPCWSTR optional
' OptionID : DWORD
Declare PtrSafe Function DhcpRemoveOption Lib "dhcpsapi" ( _
ByVal ServerIpAddress As LongPtr, _
ByVal OptionID As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DhcpRemoveOption = ctypes.windll.dhcpsapi.DhcpRemoveOption
DhcpRemoveOption.restype = wintypes.DWORD
DhcpRemoveOption.argtypes = [
wintypes.LPCWSTR, # ServerIpAddress : LPCWSTR optional
wintypes.DWORD, # OptionID : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpRemoveOption = Fiddle::Function.new(
lib['DhcpRemoveOption'],
[
Fiddle::TYPE_VOIDP, # ServerIpAddress : LPCWSTR optional
-Fiddle::TYPE_INT, # OptionID : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "dhcpsapi")]
extern "system" {
fn DhcpRemoveOption(
ServerIpAddress: *const u16, // LPCWSTR optional
OptionID: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("DHCPSAPI.dll")]
public static extern uint DhcpRemoveOption([MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, uint OptionID);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpRemoveOption' -Namespace Win32 -PassThru
# $api::DhcpRemoveOption(ServerIpAddress, OptionID)#uselib "DHCPSAPI.dll"
#func global DhcpRemoveOption "DhcpRemoveOption" sptr, sptr
; DhcpRemoveOption ServerIpAddress, OptionID ; 戻り値は stat
; ServerIpAddress : LPCWSTR optional -> "sptr"
; OptionID : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "DHCPSAPI.dll"
#cfunc global DhcpRemoveOption "DhcpRemoveOption" wstr, int
; res = DhcpRemoveOption(ServerIpAddress, OptionID)
; ServerIpAddress : LPCWSTR optional -> "wstr"
; OptionID : DWORD -> "int"; DWORD DhcpRemoveOption(LPCWSTR ServerIpAddress, DWORD OptionID)
#uselib "DHCPSAPI.dll"
#cfunc global DhcpRemoveOption "DhcpRemoveOption" wstr, int
; res = DhcpRemoveOption(ServerIpAddress, OptionID)
; ServerIpAddress : LPCWSTR optional -> "wstr"
; OptionID : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
procDhcpRemoveOption = dhcpsapi.NewProc("DhcpRemoveOption")
)
// ServerIpAddress (LPCWSTR optional), OptionID (DWORD)
r1, _, err := procDhcpRemoveOption.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerIpAddress))),
uintptr(OptionID),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction DhcpRemoveOption(
ServerIpAddress: PWideChar; // LPCWSTR optional
OptionID: DWORD // DWORD
): DWORD; stdcall;
external 'DHCPSAPI.dll' name 'DhcpRemoveOption';result := DllCall("DHCPSAPI\DhcpRemoveOption"
, "WStr", ServerIpAddress ; LPCWSTR optional
, "UInt", OptionID ; DWORD
, "UInt") ; return: DWORD●DhcpRemoveOption(ServerIpAddress, OptionID) = DLL("DHCPSAPI.dll", "dword DhcpRemoveOption(char*, dword)")
# 呼び出し: DhcpRemoveOption(ServerIpAddress, OptionID)
# ServerIpAddress : LPCWSTR optional -> "char*"
# OptionID : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "dhcpsapi" fn DhcpRemoveOption(
ServerIpAddress: [*c]const u16, // LPCWSTR optional
OptionID: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;proc DhcpRemoveOption(
ServerIpAddress: WideCString, # LPCWSTR optional
OptionID: uint32 # DWORD
): uint32 {.importc: "DhcpRemoveOption", stdcall, dynlib: "DHCPSAPI.dll".}pragma(lib, "dhcpsapi");
extern(Windows)
uint DhcpRemoveOption(
const(wchar)* ServerIpAddress, // LPCWSTR optional
uint OptionID // DWORD
);ccall((:DhcpRemoveOption, "DHCPSAPI.dll"), stdcall, UInt32,
(Cwstring, UInt32),
ServerIpAddress, OptionID)
# ServerIpAddress : LPCWSTR optional -> Cwstring
# OptionID : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t DhcpRemoveOption(
const uint16_t* ServerIpAddress,
uint32_t OptionID);
]]
local dhcpsapi = ffi.load("dhcpsapi")
-- dhcpsapi.DhcpRemoveOption(ServerIpAddress, OptionID)
-- ServerIpAddress : LPCWSTR optional
-- OptionID : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('DHCPSAPI.dll');
const DhcpRemoveOption = lib.func('__stdcall', 'DhcpRemoveOption', 'uint32_t', ['str16', 'uint32_t']);
// DhcpRemoveOption(ServerIpAddress, OptionID)
// ServerIpAddress : LPCWSTR optional -> 'str16'
// OptionID : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("DHCPSAPI.dll", {
DhcpRemoveOption: { parameters: ["buffer", "u32"], result: "u32" },
});
// lib.symbols.DhcpRemoveOption(ServerIpAddress, OptionID)
// ServerIpAddress : LPCWSTR optional -> "buffer"
// OptionID : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t DhcpRemoveOption(
const uint16_t* ServerIpAddress,
uint32_t OptionID);
C, "DHCPSAPI.dll");
// $ffi->DhcpRemoveOption(ServerIpAddress, OptionID);
// ServerIpAddress : LPCWSTR optional
// OptionID : DWORD
// 構造体/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 DhcpRemoveOption(
WString ServerIpAddress, // LPCWSTR optional
int OptionID // DWORD
);
}@[Link("dhcpsapi")]
lib LibDHCPSAPI
fun DhcpRemoveOption = DhcpRemoveOption(
ServerIpAddress : UInt16*, # LPCWSTR optional
OptionID : UInt32 # DWORD
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DhcpRemoveOptionNative = Uint32 Function(Pointer<Utf16>, Uint32);
typedef DhcpRemoveOptionDart = int Function(Pointer<Utf16>, int);
final DhcpRemoveOption = DynamicLibrary.open('DHCPSAPI.dll')
.lookupFunction<DhcpRemoveOptionNative, DhcpRemoveOptionDart>('DhcpRemoveOption');
// ServerIpAddress : LPCWSTR optional -> Pointer<Utf16>
// OptionID : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DhcpRemoveOption(
ServerIpAddress: PWideChar; // LPCWSTR optional
OptionID: DWORD // DWORD
): DWORD; stdcall;
external 'DHCPSAPI.dll' name 'DhcpRemoveOption';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DhcpRemoveOption"
c_DhcpRemoveOption :: CWString -> Word32 -> IO Word32
-- ServerIpAddress : LPCWSTR optional -> CWString
-- OptionID : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dhcpremoveoption =
foreign "DhcpRemoveOption"
((ptr uint16_t) @-> uint32_t @-> returning uint32_t)
(* ServerIpAddress : LPCWSTR optional -> (ptr uint16_t) *)
(* OptionID : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library dhcpsapi (t "DHCPSAPI.dll"))
(cffi:use-foreign-library dhcpsapi)
(cffi:defcfun ("DhcpRemoveOption" dhcp-remove-option :convention :stdcall) :uint32
(server-ip-address (:string :encoding :utf-16le)) ; LPCWSTR optional
(option-id :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DhcpRemoveOption = Win32::API::More->new('DHCPSAPI',
'DWORD DhcpRemoveOption(LPCWSTR ServerIpAddress, DWORD OptionID)');
# my $ret = $DhcpRemoveOption->Call($ServerIpAddress, $OptionID);
# ServerIpAddress : LPCWSTR optional -> LPCWSTR
# OptionID : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。