ホーム › NetworkManagement.Dhcp › DhcpHlprFindV4DhcpProperty
DhcpHlprFindV4DhcpProperty
関数プロパティ配列から指定IDと型に一致するDHCPプロパティを検索する。
シグネチャ
// DHCPSAPI.dll
#include <windows.h>
DHCP_PROPERTY* DhcpHlprFindV4DhcpProperty(
DHCP_PROPERTY_ARRAY* PropertyArray,
DHCP_PROPERTY_ID ID,
DHCP_PROPERTY_TYPE Type
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| PropertyArray | DHCP_PROPERTY_ARRAY* | in |
| ID | DHCP_PROPERTY_ID | in |
| Type | DHCP_PROPERTY_TYPE | in |
戻り値の型: DHCP_PROPERTY*
各言語での呼び出し定義
// DHCPSAPI.dll
#include <windows.h>
DHCP_PROPERTY* DhcpHlprFindV4DhcpProperty(
DHCP_PROPERTY_ARRAY* PropertyArray,
DHCP_PROPERTY_ID ID,
DHCP_PROPERTY_TYPE Type
);[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern IntPtr DhcpHlprFindV4DhcpProperty(
IntPtr PropertyArray, // DHCP_PROPERTY_ARRAY*
int ID, // DHCP_PROPERTY_ID
int Type // DHCP_PROPERTY_TYPE
);<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpHlprFindV4DhcpProperty(
PropertyArray As IntPtr, ' DHCP_PROPERTY_ARRAY*
ID As Integer, ' DHCP_PROPERTY_ID
Type As Integer ' DHCP_PROPERTY_TYPE
) As IntPtr
End Function' PropertyArray : DHCP_PROPERTY_ARRAY*
' ID : DHCP_PROPERTY_ID
' Type : DHCP_PROPERTY_TYPE
Declare PtrSafe Function DhcpHlprFindV4DhcpProperty Lib "dhcpsapi" ( _
ByVal PropertyArray As LongPtr, _
ByVal ID As Long, _
ByVal Type As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DhcpHlprFindV4DhcpProperty = ctypes.windll.dhcpsapi.DhcpHlprFindV4DhcpProperty
DhcpHlprFindV4DhcpProperty.restype = ctypes.c_void_p
DhcpHlprFindV4DhcpProperty.argtypes = [
ctypes.c_void_p, # PropertyArray : DHCP_PROPERTY_ARRAY*
ctypes.c_int, # ID : DHCP_PROPERTY_ID
ctypes.c_int, # Type : DHCP_PROPERTY_TYPE
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpHlprFindV4DhcpProperty = Fiddle::Function.new(
lib['DhcpHlprFindV4DhcpProperty'],
[
Fiddle::TYPE_VOIDP, # PropertyArray : DHCP_PROPERTY_ARRAY*
Fiddle::TYPE_INT, # ID : DHCP_PROPERTY_ID
Fiddle::TYPE_INT, # Type : DHCP_PROPERTY_TYPE
],
Fiddle::TYPE_VOIDP)#[link(name = "dhcpsapi")]
extern "system" {
fn DhcpHlprFindV4DhcpProperty(
PropertyArray: *mut DHCP_PROPERTY_ARRAY, // DHCP_PROPERTY_ARRAY*
ID: i32, // DHCP_PROPERTY_ID
Type: i32 // DHCP_PROPERTY_TYPE
) -> *mut DHCP_PROPERTY;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("DHCPSAPI.dll")]
public static extern IntPtr DhcpHlprFindV4DhcpProperty(IntPtr PropertyArray, int ID, int Type);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpHlprFindV4DhcpProperty' -Namespace Win32 -PassThru
# $api::DhcpHlprFindV4DhcpProperty(PropertyArray, ID, Type)#uselib "DHCPSAPI.dll"
#func global DhcpHlprFindV4DhcpProperty "DhcpHlprFindV4DhcpProperty" sptr, sptr, sptr
; DhcpHlprFindV4DhcpProperty varptr(PropertyArray), ID, Type ; 戻り値は stat
; PropertyArray : DHCP_PROPERTY_ARRAY* -> "sptr"
; ID : DHCP_PROPERTY_ID -> "sptr"
; Type : DHCP_PROPERTY_TYPE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "DHCPSAPI.dll" #cfunc global DhcpHlprFindV4DhcpProperty "DhcpHlprFindV4DhcpProperty" var, int, int ; res = DhcpHlprFindV4DhcpProperty(PropertyArray, ID, Type) ; PropertyArray : DHCP_PROPERTY_ARRAY* -> "var" ; ID : DHCP_PROPERTY_ID -> "int" ; Type : DHCP_PROPERTY_TYPE -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "DHCPSAPI.dll" #cfunc global DhcpHlprFindV4DhcpProperty "DhcpHlprFindV4DhcpProperty" sptr, int, int ; res = DhcpHlprFindV4DhcpProperty(varptr(PropertyArray), ID, Type) ; PropertyArray : DHCP_PROPERTY_ARRAY* -> "sptr" ; ID : DHCP_PROPERTY_ID -> "int" ; Type : DHCP_PROPERTY_TYPE -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DHCP_PROPERTY* DhcpHlprFindV4DhcpProperty(DHCP_PROPERTY_ARRAY* PropertyArray, DHCP_PROPERTY_ID ID, DHCP_PROPERTY_TYPE Type) #uselib "DHCPSAPI.dll" #cfunc global DhcpHlprFindV4DhcpProperty "DhcpHlprFindV4DhcpProperty" var, int, int ; res = DhcpHlprFindV4DhcpProperty(PropertyArray, ID, Type) ; PropertyArray : DHCP_PROPERTY_ARRAY* -> "var" ; ID : DHCP_PROPERTY_ID -> "int" ; Type : DHCP_PROPERTY_TYPE -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DHCP_PROPERTY* DhcpHlprFindV4DhcpProperty(DHCP_PROPERTY_ARRAY* PropertyArray, DHCP_PROPERTY_ID ID, DHCP_PROPERTY_TYPE Type) #uselib "DHCPSAPI.dll" #cfunc global DhcpHlprFindV4DhcpProperty "DhcpHlprFindV4DhcpProperty" intptr, int, int ; res = DhcpHlprFindV4DhcpProperty(varptr(PropertyArray), ID, Type) ; PropertyArray : DHCP_PROPERTY_ARRAY* -> "intptr" ; ID : DHCP_PROPERTY_ID -> "int" ; Type : DHCP_PROPERTY_TYPE -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
procDhcpHlprFindV4DhcpProperty = dhcpsapi.NewProc("DhcpHlprFindV4DhcpProperty")
)
// PropertyArray (DHCP_PROPERTY_ARRAY*), ID (DHCP_PROPERTY_ID), Type (DHCP_PROPERTY_TYPE)
r1, _, err := procDhcpHlprFindV4DhcpProperty.Call(
uintptr(PropertyArray),
uintptr(ID),
uintptr(Type),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DHCP_PROPERTY*function DhcpHlprFindV4DhcpProperty(
PropertyArray: Pointer; // DHCP_PROPERTY_ARRAY*
ID: Integer; // DHCP_PROPERTY_ID
Type: Integer // DHCP_PROPERTY_TYPE
): Pointer; stdcall;
external 'DHCPSAPI.dll' name 'DhcpHlprFindV4DhcpProperty';result := DllCall("DHCPSAPI\DhcpHlprFindV4DhcpProperty"
, "Ptr", PropertyArray ; DHCP_PROPERTY_ARRAY*
, "Int", ID ; DHCP_PROPERTY_ID
, "Int", Type ; DHCP_PROPERTY_TYPE
, "Ptr") ; return: DHCP_PROPERTY*●DhcpHlprFindV4DhcpProperty(PropertyArray, ID, Type) = DLL("DHCPSAPI.dll", "void* DhcpHlprFindV4DhcpProperty(void*, int, int)")
# 呼び出し: DhcpHlprFindV4DhcpProperty(PropertyArray, ID, Type)
# PropertyArray : DHCP_PROPERTY_ARRAY* -> "void*"
# ID : DHCP_PROPERTY_ID -> "int"
# Type : DHCP_PROPERTY_TYPE -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。