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

DhcpV4FailoverTriggerAddrAllocation

関数
IPv4フェールオーバー関係のアドレス再割り当てを起動する。
DLLDHCPSAPI.dll呼出規約winapi対応OSwindowsserver2012

シグネチャ

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

DWORD DhcpV4FailoverTriggerAddrAllocation(
    LPWSTR ServerIpAddress,   // optional
    LPWSTR pFailRelName
);

パラメーター

名前方向
ServerIpAddressLPWSTRinoptional
pFailRelNameLPWSTRin

戻り値の型: DWORD

各言語での呼び出し定義

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

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

DhcpV4FailoverTriggerAddrAllocation = ctypes.windll.dhcpsapi.DhcpV4FailoverTriggerAddrAllocation
DhcpV4FailoverTriggerAddrAllocation.restype = wintypes.DWORD
DhcpV4FailoverTriggerAddrAllocation.argtypes = [
    wintypes.LPCWSTR,  # ServerIpAddress : LPWSTR optional
    wintypes.LPCWSTR,  # pFailRelName : LPWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpV4FailoverTriggerAddrAllocation = Fiddle::Function.new(
  lib['DhcpV4FailoverTriggerAddrAllocation'],
  [
    Fiddle::TYPE_VOIDP,  # ServerIpAddress : LPWSTR optional
    Fiddle::TYPE_VOIDP,  # pFailRelName : LPWSTR
  ],
  -Fiddle::TYPE_INT)
#[link(name = "dhcpsapi")]
extern "system" {
    fn DhcpV4FailoverTriggerAddrAllocation(
        ServerIpAddress: *mut u16,  // LPWSTR optional
        pFailRelName: *mut u16  // LPWSTR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("DHCPSAPI.dll")]
public static extern uint DhcpV4FailoverTriggerAddrAllocation([MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, [MarshalAs(UnmanagedType.LPWStr)] string pFailRelName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpV4FailoverTriggerAddrAllocation' -Namespace Win32 -PassThru
# $api::DhcpV4FailoverTriggerAddrAllocation(ServerIpAddress, pFailRelName)
#uselib "DHCPSAPI.dll"
#func global DhcpV4FailoverTriggerAddrAllocation "DhcpV4FailoverTriggerAddrAllocation" sptr, sptr
; DhcpV4FailoverTriggerAddrAllocation ServerIpAddress, pFailRelName   ; 戻り値は stat
; ServerIpAddress : LPWSTR optional -> "sptr"
; pFailRelName : LPWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "DHCPSAPI.dll"
#cfunc global DhcpV4FailoverTriggerAddrAllocation "DhcpV4FailoverTriggerAddrAllocation" wstr, wstr
; res = DhcpV4FailoverTriggerAddrAllocation(ServerIpAddress, pFailRelName)
; ServerIpAddress : LPWSTR optional -> "wstr"
; pFailRelName : LPWSTR -> "wstr"
; DWORD DhcpV4FailoverTriggerAddrAllocation(LPWSTR ServerIpAddress, LPWSTR pFailRelName)
#uselib "DHCPSAPI.dll"
#cfunc global DhcpV4FailoverTriggerAddrAllocation "DhcpV4FailoverTriggerAddrAllocation" wstr, wstr
; res = DhcpV4FailoverTriggerAddrAllocation(ServerIpAddress, pFailRelName)
; ServerIpAddress : LPWSTR optional -> "wstr"
; pFailRelName : LPWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpV4FailoverTriggerAddrAllocation = dhcpsapi.NewProc("DhcpV4FailoverTriggerAddrAllocation")
)

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