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