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

DhcpV4FailoverDeleteRelationship

関数
指定したIPv4フェールオーバー関係を削除する。
DLLDHCPSAPI.dll呼出規約winapi対応OSwindowsserver2012

シグネチャ

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

DWORD DhcpV4FailoverDeleteRelationship(
    LPWSTR ServerIpAddress,   // optional
    LPWSTR pRelationshipName
);

パラメーター

名前方向説明
ServerIpAddressLPWSTRinoptional対象DHCPサーバーのIPアドレスを示すUnicode文字列。ローカルならNULL可。
pRelationshipNameLPWSTRin削除するフェールオーバー関係の名前を示す文字列。

戻り値の型: DWORD

各言語での呼び出し定義

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

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

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

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

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpV4FailoverDeleteRelationship = dhcpsapi.NewProc("DhcpV4FailoverDeleteRelationship")
)

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

extern "dhcpsapi" fn DhcpV4FailoverDeleteRelationship(
    ServerIpAddress: [*c]const u16, // LPWSTR optional
    pRelationshipName: [*c]const u16 // LPWSTR
) callconv(std.os.windows.WINAPI) u32;
proc DhcpV4FailoverDeleteRelationship(
    ServerIpAddress: WideCString,  # LPWSTR optional
    pRelationshipName: WideCString  # LPWSTR
): uint32 {.importc: "DhcpV4FailoverDeleteRelationship", stdcall, dynlib: "DHCPSAPI.dll".}
pragma(lib, "dhcpsapi");
extern(Windows)
uint DhcpV4FailoverDeleteRelationship(
    const(wchar)* ServerIpAddress,   // LPWSTR optional
    const(wchar)* pRelationshipName   // LPWSTR
);
ccall((:DhcpV4FailoverDeleteRelationship, "DHCPSAPI.dll"), stdcall, UInt32,
      (Cwstring, Cwstring),
      ServerIpAddress, pRelationshipName)
# ServerIpAddress : LPWSTR optional -> Cwstring
# pRelationshipName : LPWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t DhcpV4FailoverDeleteRelationship(
    const uint16_t* ServerIpAddress,
    const uint16_t* pRelationshipName);
]]
local dhcpsapi = ffi.load("dhcpsapi")
-- dhcpsapi.DhcpV4FailoverDeleteRelationship(ServerIpAddress, pRelationshipName)
-- ServerIpAddress : LPWSTR optional
-- pRelationshipName : LPWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('DHCPSAPI.dll');
const DhcpV4FailoverDeleteRelationship = lib.func('__stdcall', 'DhcpV4FailoverDeleteRelationship', 'uint32_t', ['str16', 'str16']);
// DhcpV4FailoverDeleteRelationship(ServerIpAddress, pRelationshipName)
// ServerIpAddress : LPWSTR optional -> 'str16'
// pRelationshipName : LPWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("DHCPSAPI.dll", {
  DhcpV4FailoverDeleteRelationship: { parameters: ["buffer", "buffer"], result: "u32" },
});
// lib.symbols.DhcpV4FailoverDeleteRelationship(ServerIpAddress, pRelationshipName)
// ServerIpAddress : LPWSTR optional -> "buffer"
// pRelationshipName : LPWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t DhcpV4FailoverDeleteRelationship(
    const uint16_t* ServerIpAddress,
    const uint16_t* pRelationshipName);
C, "DHCPSAPI.dll");
// $ffi->DhcpV4FailoverDeleteRelationship(ServerIpAddress, pRelationshipName);
// ServerIpAddress : LPWSTR optional
// pRelationshipName : LPWSTR
// 構造体/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 DhcpV4FailoverDeleteRelationship(
        WString ServerIpAddress,   // LPWSTR optional
        WString pRelationshipName   // LPWSTR
    );
}
@[Link("dhcpsapi")]
lib LibDHCPSAPI
  fun DhcpV4FailoverDeleteRelationship = DhcpV4FailoverDeleteRelationship(
    ServerIpAddress : UInt16*,   # LPWSTR optional
    pRelationshipName : UInt16*   # LPWSTR
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef DhcpV4FailoverDeleteRelationshipNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>);
typedef DhcpV4FailoverDeleteRelationshipDart = int Function(Pointer<Utf16>, Pointer<Utf16>);
final DhcpV4FailoverDeleteRelationship = DynamicLibrary.open('DHCPSAPI.dll')
    .lookupFunction<DhcpV4FailoverDeleteRelationshipNative, DhcpV4FailoverDeleteRelationshipDart>('DhcpV4FailoverDeleteRelationship');
// ServerIpAddress : LPWSTR optional -> Pointer<Utf16>
// pRelationshipName : LPWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function DhcpV4FailoverDeleteRelationship(
  ServerIpAddress: PWideChar;   // LPWSTR optional
  pRelationshipName: PWideChar   // LPWSTR
): DWORD; stdcall;
  external 'DHCPSAPI.dll' name 'DhcpV4FailoverDeleteRelationship';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "DhcpV4FailoverDeleteRelationship"
  c_DhcpV4FailoverDeleteRelationship :: CWString -> CWString -> IO Word32
-- ServerIpAddress : LPWSTR optional -> CWString
-- pRelationshipName : LPWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let dhcpv4failoverdeleterelationship =
  foreign "DhcpV4FailoverDeleteRelationship"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> returning uint32_t)
(* ServerIpAddress : LPWSTR optional -> (ptr uint16_t) *)
(* pRelationshipName : LPWSTR -> (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 ("DhcpV4FailoverDeleteRelationship" dhcp-v4-failover-delete-relationship :convention :stdcall) :uint32
  (server-ip-address (:string :encoding :utf-16le))   ; LPWSTR optional
  (p-relationship-name (:string :encoding :utf-16le)))   ; LPWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $DhcpV4FailoverDeleteRelationship = Win32::API::More->new('DHCPSAPI',
    'DWORD DhcpV4FailoverDeleteRelationship(LPCWSTR ServerIpAddress, LPCWSTR pRelationshipName)');
# my $ret = $DhcpV4FailoverDeleteRelationship->Call($ServerIpAddress, $pRelationshipName);
# ServerIpAddress : LPWSTR optional -> LPCWSTR
# pRelationshipName : LPWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。