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

DhcpSetThreadOptions

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

シグネチャ

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

DWORD DhcpSetThreadOptions(
    DWORD Flags,
    void* Reserved
);

パラメーター

名前方向
FlagsDWORDin
Reservedvoid*inout

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD DhcpSetThreadOptions(
    DWORD Flags,
    void* Reserved
);
[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpSetThreadOptions(
    uint Flags,   // DWORD
    IntPtr Reserved   // void* in/out
);
<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpSetThreadOptions(
    Flags As UInteger,   ' DWORD
    Reserved As IntPtr   ' void* in/out
) As UInteger
End Function
' Flags : DWORD
' Reserved : void* in/out
Declare PtrSafe Function DhcpSetThreadOptions Lib "dhcpsapi" ( _
    ByVal Flags 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

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

lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpSetThreadOptions = Fiddle::Function.new(
  lib['DhcpSetThreadOptions'],
  [
    -Fiddle::TYPE_INT,  # Flags : DWORD
    Fiddle::TYPE_VOIDP,  # Reserved : void* in/out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "dhcpsapi")]
extern "system" {
    fn DhcpSetThreadOptions(
        Flags: u32,  // DWORD
        Reserved: *mut ()  // void* in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("DHCPSAPI.dll")]
public static extern uint DhcpSetThreadOptions(uint Flags, IntPtr Reserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpSetThreadOptions' -Namespace Win32 -PassThru
# $api::DhcpSetThreadOptions(Flags, Reserved)
#uselib "DHCPSAPI.dll"
#func global DhcpSetThreadOptions "DhcpSetThreadOptions" sptr, sptr
; DhcpSetThreadOptions Flags, Reserved   ; 戻り値は stat
; Flags : DWORD -> "sptr"
; Reserved : void* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "DHCPSAPI.dll"
#cfunc global DhcpSetThreadOptions "DhcpSetThreadOptions" int, sptr
; res = DhcpSetThreadOptions(Flags, Reserved)
; Flags : DWORD -> "int"
; Reserved : void* in/out -> "sptr"
; DWORD DhcpSetThreadOptions(DWORD Flags, void* Reserved)
#uselib "DHCPSAPI.dll"
#cfunc global DhcpSetThreadOptions "DhcpSetThreadOptions" int, intptr
; res = DhcpSetThreadOptions(Flags, Reserved)
; Flags : DWORD -> "int"
; Reserved : void* in/out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpSetThreadOptions = dhcpsapi.NewProc("DhcpSetThreadOptions")
)

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