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