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

DhcpServerRedoAuthorization

関数
DHCPサーバーの認可状態を再評価する。
DLLDHCPSAPI.dll呼出規約winapi対応OSwindowsserver2000

シグネチャ

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

DWORD DhcpServerRedoAuthorization(
    LPWSTR ServerIpAddr,   // optional
    DWORD dwReserved
);

パラメーター

名前方向説明
ServerIpAddrLPWSTRinoptional対象DHCPサーバーのIPアドレスを示すUnicode文字列。ローカルならNULL可。
dwReservedDWORDin予約済みパラメーター。0を指定する。

戻り値の型: DWORD

各言語での呼び出し定義

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

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

DhcpServerRedoAuthorization = ctypes.windll.dhcpsapi.DhcpServerRedoAuthorization
DhcpServerRedoAuthorization.restype = wintypes.DWORD
DhcpServerRedoAuthorization.argtypes = [
    wintypes.LPCWSTR,  # ServerIpAddr : LPWSTR optional
    wintypes.DWORD,  # dwReserved : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpServerRedoAuthorization = dhcpsapi.NewProc("DhcpServerRedoAuthorization")
)

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

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

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

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

let dhcpserverredoauthorization =
  foreign "DhcpServerRedoAuthorization"
    ((ptr uint16_t) @-> uint32_t @-> returning uint32_t)
(* ServerIpAddr : LPWSTR optional -> (ptr uint16_t) *)
(* dwReserved : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library dhcpsapi (t "DHCPSAPI.dll"))
(cffi:use-foreign-library dhcpsapi)

(cffi:defcfun ("DhcpServerRedoAuthorization" dhcp-server-redo-authorization :convention :stdcall) :uint32
  (server-ip-addr (:string :encoding :utf-16le))   ; LPWSTR optional
  (dw-reserved :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $DhcpServerRedoAuthorization = Win32::API::More->new('DHCPSAPI',
    'DWORD DhcpServerRedoAuthorization(LPCWSTR ServerIpAddr, DWORD dwReserved)');
# my $ret = $DhcpServerRedoAuthorization->Call($ServerIpAddr, $dwReserved);
# ServerIpAddr : LPWSTR optional -> LPCWSTR
# dwReserved : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。