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

DhcpGetThreadOptions

関数
現在のスレッドのDHCP API動作オプションを取得する。
DLLDHCPSAPI.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

DWORD DhcpGetThreadOptions(
    DWORD* pFlags,
    void* Reserved
);

パラメーター

名前方向
pFlagsDWORD*inout
Reservedvoid*inout

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD DhcpGetThreadOptions(
    DWORD* pFlags,
    void* Reserved
);
[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpGetThreadOptions(
    ref uint pFlags,   // DWORD* in/out
    IntPtr Reserved   // void* in/out
);
<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpGetThreadOptions(
    ByRef pFlags As UInteger,   ' DWORD* in/out
    Reserved As IntPtr   ' void* in/out
) As UInteger
End Function
' pFlags : DWORD* in/out
' Reserved : void* in/out
Declare PtrSafe Function DhcpGetThreadOptions Lib "dhcpsapi" ( _
    ByRef pFlags As Long, _
    ByVal Reserved As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DhcpGetThreadOptions = ctypes.windll.dhcpsapi.DhcpGetThreadOptions
DhcpGetThreadOptions.restype = wintypes.DWORD
DhcpGetThreadOptions.argtypes = [
    ctypes.POINTER(wintypes.DWORD),  # pFlags : DWORD* in/out
    ctypes.POINTER(None),  # Reserved : void* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpGetThreadOptions = dhcpsapi.NewProc("DhcpGetThreadOptions")
)

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