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