Win32 API 日本語リファレンス
ホームNetworkManagement.Dhcp › DhcpV4FailoverGetSystemTime

DhcpV4FailoverGetSystemTime

関数
DHCPサーバーのシステム時刻と許容時刻差を取得する。
DLLDHCPSAPI.dll呼出規約winapi対応OSwindowsserver2012

シグネチャ

// DHCPSAPI.dll
#include <windows.h>

DWORD DhcpV4FailoverGetSystemTime(
    LPWSTR ServerIpAddress,   // optional
    DWORD* pTime,
    DWORD* pMaxAllowedDeltaTime
);

パラメーター

名前方向
ServerIpAddressLPWSTRinoptional
pTimeDWORD*out
pMaxAllowedDeltaTimeDWORD*out

戻り値の型: DWORD

各言語での呼び出し定義

// DHCPSAPI.dll
#include <windows.h>

DWORD DhcpV4FailoverGetSystemTime(
    LPWSTR ServerIpAddress,   // optional
    DWORD* pTime,
    DWORD* pMaxAllowedDeltaTime
);
[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpV4FailoverGetSystemTime(
    [MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress,   // LPWSTR optional
    out uint pTime,   // DWORD* out
    out uint pMaxAllowedDeltaTime   // DWORD* out
);
<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpV4FailoverGetSystemTime(
    <MarshalAs(UnmanagedType.LPWStr)> ServerIpAddress As String,   ' LPWSTR optional
    <Out> ByRef pTime As UInteger,   ' DWORD* out
    <Out> ByRef pMaxAllowedDeltaTime As UInteger   ' DWORD* out
) As UInteger
End Function
' ServerIpAddress : LPWSTR optional
' pTime : DWORD* out
' pMaxAllowedDeltaTime : DWORD* out
Declare PtrSafe Function DhcpV4FailoverGetSystemTime Lib "dhcpsapi" ( _
    ByVal ServerIpAddress As LongPtr, _
    ByRef pTime As Long, _
    ByRef pMaxAllowedDeltaTime As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DhcpV4FailoverGetSystemTime = ctypes.windll.dhcpsapi.DhcpV4FailoverGetSystemTime
DhcpV4FailoverGetSystemTime.restype = wintypes.DWORD
DhcpV4FailoverGetSystemTime.argtypes = [
    wintypes.LPCWSTR,  # ServerIpAddress : LPWSTR optional
    ctypes.POINTER(wintypes.DWORD),  # pTime : DWORD* out
    ctypes.POINTER(wintypes.DWORD),  # pMaxAllowedDeltaTime : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpV4FailoverGetSystemTime = Fiddle::Function.new(
  lib['DhcpV4FailoverGetSystemTime'],
  [
    Fiddle::TYPE_VOIDP,  # ServerIpAddress : LPWSTR optional
    Fiddle::TYPE_VOIDP,  # pTime : DWORD* out
    Fiddle::TYPE_VOIDP,  # pMaxAllowedDeltaTime : DWORD* out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "dhcpsapi")]
extern "system" {
    fn DhcpV4FailoverGetSystemTime(
        ServerIpAddress: *mut u16,  // LPWSTR optional
        pTime: *mut u32,  // DWORD* out
        pMaxAllowedDeltaTime: *mut u32  // DWORD* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("DHCPSAPI.dll")]
public static extern uint DhcpV4FailoverGetSystemTime([MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, out uint pTime, out uint pMaxAllowedDeltaTime);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpV4FailoverGetSystemTime' -Namespace Win32 -PassThru
# $api::DhcpV4FailoverGetSystemTime(ServerIpAddress, pTime, pMaxAllowedDeltaTime)
#uselib "DHCPSAPI.dll"
#func global DhcpV4FailoverGetSystemTime "DhcpV4FailoverGetSystemTime" sptr, sptr, sptr
; DhcpV4FailoverGetSystemTime ServerIpAddress, varptr(pTime), varptr(pMaxAllowedDeltaTime)   ; 戻り値は stat
; ServerIpAddress : LPWSTR optional -> "sptr"
; pTime : DWORD* out -> "sptr"
; pMaxAllowedDeltaTime : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "DHCPSAPI.dll"
#cfunc global DhcpV4FailoverGetSystemTime "DhcpV4FailoverGetSystemTime" wstr, var, var
; res = DhcpV4FailoverGetSystemTime(ServerIpAddress, pTime, pMaxAllowedDeltaTime)
; ServerIpAddress : LPWSTR optional -> "wstr"
; pTime : DWORD* out -> "var"
; pMaxAllowedDeltaTime : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD DhcpV4FailoverGetSystemTime(LPWSTR ServerIpAddress, DWORD* pTime, DWORD* pMaxAllowedDeltaTime)
#uselib "DHCPSAPI.dll"
#cfunc global DhcpV4FailoverGetSystemTime "DhcpV4FailoverGetSystemTime" wstr, var, var
; res = DhcpV4FailoverGetSystemTime(ServerIpAddress, pTime, pMaxAllowedDeltaTime)
; ServerIpAddress : LPWSTR optional -> "wstr"
; pTime : DWORD* out -> "var"
; pMaxAllowedDeltaTime : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpV4FailoverGetSystemTime = dhcpsapi.NewProc("DhcpV4FailoverGetSystemTime")
)

// ServerIpAddress (LPWSTR optional), pTime (DWORD* out), pMaxAllowedDeltaTime (DWORD* out)
r1, _, err := procDhcpV4FailoverGetSystemTime.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerIpAddress))),
	uintptr(pTime),
	uintptr(pMaxAllowedDeltaTime),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function DhcpV4FailoverGetSystemTime(
  ServerIpAddress: PWideChar;   // LPWSTR optional
  pTime: Pointer;   // DWORD* out
  pMaxAllowedDeltaTime: Pointer   // DWORD* out
): DWORD; stdcall;
  external 'DHCPSAPI.dll' name 'DhcpV4FailoverGetSystemTime';
result := DllCall("DHCPSAPI\DhcpV4FailoverGetSystemTime"
    , "WStr", ServerIpAddress   ; LPWSTR optional
    , "Ptr", pTime   ; DWORD* out
    , "Ptr", pMaxAllowedDeltaTime   ; DWORD* out
    , "UInt")   ; return: DWORD
●DhcpV4FailoverGetSystemTime(ServerIpAddress, pTime, pMaxAllowedDeltaTime) = DLL("DHCPSAPI.dll", "dword DhcpV4FailoverGetSystemTime(char*, void*, void*)")
# 呼び出し: DhcpV4FailoverGetSystemTime(ServerIpAddress, pTime, pMaxAllowedDeltaTime)
# ServerIpAddress : LPWSTR optional -> "char*"
# pTime : DWORD* out -> "void*"
# pMaxAllowedDeltaTime : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。