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

DhcpServerSetConfigVQ

関数
DHCPサーバーのVQ拡張付き構成パラメータを設定する。
DLLDHCPSAPI.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

DWORD DhcpServerSetConfigVQ(
    LPCWSTR ServerIpAddress,   // optional
    DWORD FieldsToSet,
    DHCP_SERVER_CONFIG_INFO_VQ* ConfigInfo
);

パラメーター

名前方向
ServerIpAddressLPCWSTRinoptional
FieldsToSetDWORDin
ConfigInfoDHCP_SERVER_CONFIG_INFO_VQ*inout

戻り値の型: DWORD

各言語での呼び出し定義

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

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

DhcpServerSetConfigVQ = ctypes.windll.dhcpsapi.DhcpServerSetConfigVQ
DhcpServerSetConfigVQ.restype = wintypes.DWORD
DhcpServerSetConfigVQ.argtypes = [
    wintypes.LPCWSTR,  # ServerIpAddress : LPCWSTR optional
    wintypes.DWORD,  # FieldsToSet : DWORD
    ctypes.c_void_p,  # ConfigInfo : DHCP_SERVER_CONFIG_INFO_VQ* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpServerSetConfigVQ = dhcpsapi.NewProc("DhcpServerSetConfigVQ")
)

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