ホーム › NetworkManagement.Dhcp › DhcpSetSubnetDelayOffer
DhcpSetSubnetDelayOffer
関数指定サブネットでのDHCPオファー応答の遅延時間を設定する。
シグネチャ
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpSetSubnetDelayOffer(
LPWSTR ServerIpAddress, // optional
DWORD SubnetAddress,
WORD TimeDelayInMilliseconds
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ServerIpAddress | LPWSTR | inoptional |
| SubnetAddress | DWORD | in |
| TimeDelayInMilliseconds | WORD | in |
戻り値の型: 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)。