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