ホーム › NetworkManagement.Dhcp › DhcpGetThreadOptions
DhcpGetThreadOptions
関数現在のスレッドのDHCP API動作オプションを取得する。
シグネチャ
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpGetThreadOptions(
DWORD* pFlags,
void* Reserved
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pFlags | DWORD* | inout | 現在のスレッドオプションフラグを受け取るDWORDへのポインタ。 |
| Reserved | void* | inout | 予約済みパラメーター。NULLを指定する。 |
戻り値の型: 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 方式にも切替可。#uselib "DHCPSAPI.dll" #cfunc global DhcpGetThreadOptions "DhcpGetThreadOptions" sptr, sptr ; res = DhcpGetThreadOptions(varptr(pFlags), Reserved) ; pFlags : DWORD* in/out -> "sptr" ; Reserved : void* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; DWORD DhcpGetThreadOptions(DWORD* pFlags, void* Reserved) #uselib "DHCPSAPI.dll" #cfunc global DhcpGetThreadOptions "DhcpGetThreadOptions" intptr, intptr ; res = DhcpGetThreadOptions(varptr(pFlags), Reserved) ; pFlags : DWORD* in/out -> "intptr" ; Reserved : void* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // DWORDfunction 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)。const std = @import("std");
extern "dhcpsapi" fn DhcpGetThreadOptions(
pFlags: [*c]u32, // DWORD* in/out
Reserved: ?*anyopaque // void* in/out
) callconv(std.os.windows.WINAPI) u32;proc DhcpGetThreadOptions(
pFlags: ptr uint32, # DWORD* in/out
Reserved: pointer # void* in/out
): uint32 {.importc: "DhcpGetThreadOptions", stdcall, dynlib: "DHCPSAPI.dll".}pragma(lib, "dhcpsapi");
extern(Windows)
uint DhcpGetThreadOptions(
uint* pFlags, // DWORD* in/out
void* Reserved // void* in/out
);ccall((:DhcpGetThreadOptions, "DHCPSAPI.dll"), stdcall, UInt32,
(Ptr{UInt32}, Ptr{Cvoid}),
pFlags, Reserved)
# pFlags : DWORD* in/out -> Ptr{UInt32}
# Reserved : void* in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t DhcpGetThreadOptions(
uint32_t* pFlags,
void* Reserved);
]]
local dhcpsapi = ffi.load("dhcpsapi")
-- dhcpsapi.DhcpGetThreadOptions(pFlags, Reserved)
-- pFlags : DWORD* in/out
-- Reserved : void* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('DHCPSAPI.dll');
const DhcpGetThreadOptions = lib.func('__stdcall', 'DhcpGetThreadOptions', 'uint32_t', ['uint32_t *', 'void *']);
// DhcpGetThreadOptions(pFlags, Reserved)
// pFlags : DWORD* in/out -> 'uint32_t *'
// Reserved : void* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("DHCPSAPI.dll", {
DhcpGetThreadOptions: { parameters: ["pointer", "pointer"], result: "u32" },
});
// lib.symbols.DhcpGetThreadOptions(pFlags, Reserved)
// pFlags : DWORD* in/out -> "pointer"
// Reserved : void* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t DhcpGetThreadOptions(
uint32_t* pFlags,
void* Reserved);
C, "DHCPSAPI.dll");
// $ffi->DhcpGetThreadOptions(pFlags, Reserved);
// pFlags : DWORD* in/out
// Reserved : void* 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 DhcpGetThreadOptions(
IntByReference pFlags, // DWORD* in/out
Pointer Reserved // void* in/out
);
}@[Link("dhcpsapi")]
lib LibDHCPSAPI
fun DhcpGetThreadOptions = DhcpGetThreadOptions(
pFlags : UInt32*, # DWORD* in/out
Reserved : Void* # void* 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 DhcpGetThreadOptionsNative = Uint32 Function(Pointer<Uint32>, Pointer<Void>);
typedef DhcpGetThreadOptionsDart = int Function(Pointer<Uint32>, Pointer<Void>);
final DhcpGetThreadOptions = DynamicLibrary.open('DHCPSAPI.dll')
.lookupFunction<DhcpGetThreadOptionsNative, DhcpGetThreadOptionsDart>('DhcpGetThreadOptions');
// pFlags : DWORD* in/out -> Pointer<Uint32>
// Reserved : void* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DhcpGetThreadOptions(
pFlags: Pointer; // DWORD* in/out
Reserved: Pointer // void* in/out
): DWORD; stdcall;
external 'DHCPSAPI.dll' name 'DhcpGetThreadOptions';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DhcpGetThreadOptions"
c_DhcpGetThreadOptions :: Ptr Word32 -> Ptr () -> IO Word32
-- pFlags : DWORD* in/out -> Ptr Word32
-- Reserved : void* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dhcpgetthreadoptions =
foreign "DhcpGetThreadOptions"
((ptr uint32_t) @-> (ptr void) @-> returning uint32_t)
(* pFlags : DWORD* in/out -> (ptr uint32_t) *)
(* Reserved : void* 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 ("DhcpGetThreadOptions" dhcp-get-thread-options :convention :stdcall) :uint32
(p-flags :pointer) ; DWORD* in/out
(reserved :pointer)) ; void* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DhcpGetThreadOptions = Win32::API::More->new('DHCPSAPI',
'DWORD DhcpGetThreadOptions(LPVOID pFlags, LPVOID Reserved)');
# my $ret = $DhcpGetThreadOptions->Call($pFlags, $Reserved);
# pFlags : DWORD* in/out -> LPVOID
# Reserved : void* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。