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

Dhcpv6RequestPrefix

関数
DHCPv6サーバーにIPv6プレフィックスの委任を要求する。
DLLdhcpcsvc6.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD Dhcpv6RequestPrefix(
    LPWSTR adapterName,
    DHCPV6CAPI_CLASSID* pclassId,
    DHCPV6PrefixLeaseInformation* prefixleaseInfo,
    DWORD* pdwTimeToWait
);

パラメーター

名前方向
adapterNameLPWSTRin
pclassIdDHCPV6CAPI_CLASSID*inout
prefixleaseInfoDHCPV6PrefixLeaseInformation*inout
pdwTimeToWaitDWORD*out

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD Dhcpv6RequestPrefix(
    LPWSTR adapterName,
    DHCPV6CAPI_CLASSID* pclassId,
    DHCPV6PrefixLeaseInformation* prefixleaseInfo,
    DWORD* pdwTimeToWait
);
[DllImport("dhcpcsvc6.dll", ExactSpelling = true)]
static extern uint Dhcpv6RequestPrefix(
    [MarshalAs(UnmanagedType.LPWStr)] string adapterName,   // LPWSTR
    IntPtr pclassId,   // DHCPV6CAPI_CLASSID* in/out
    IntPtr prefixleaseInfo,   // DHCPV6PrefixLeaseInformation* in/out
    out uint pdwTimeToWait   // DWORD* out
);
<DllImport("dhcpcsvc6.dll", ExactSpelling:=True)>
Public Shared Function Dhcpv6RequestPrefix(
    <MarshalAs(UnmanagedType.LPWStr)> adapterName As String,   ' LPWSTR
    pclassId As IntPtr,   ' DHCPV6CAPI_CLASSID* in/out
    prefixleaseInfo As IntPtr,   ' DHCPV6PrefixLeaseInformation* in/out
    <Out> ByRef pdwTimeToWait As UInteger   ' DWORD* out
) As UInteger
End Function
' adapterName : LPWSTR
' pclassId : DHCPV6CAPI_CLASSID* in/out
' prefixleaseInfo : DHCPV6PrefixLeaseInformation* in/out
' pdwTimeToWait : DWORD* out
Declare PtrSafe Function Dhcpv6RequestPrefix Lib "dhcpcsvc6" ( _
    ByVal adapterName As LongPtr, _
    ByVal pclassId As LongPtr, _
    ByVal prefixleaseInfo As LongPtr, _
    ByRef pdwTimeToWait As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

Dhcpv6RequestPrefix = ctypes.windll.dhcpcsvc6.Dhcpv6RequestPrefix
Dhcpv6RequestPrefix.restype = wintypes.DWORD
Dhcpv6RequestPrefix.argtypes = [
    wintypes.LPCWSTR,  # adapterName : LPWSTR
    ctypes.c_void_p,  # pclassId : DHCPV6CAPI_CLASSID* in/out
    ctypes.c_void_p,  # prefixleaseInfo : DHCPV6PrefixLeaseInformation* in/out
    ctypes.POINTER(wintypes.DWORD),  # pdwTimeToWait : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	dhcpcsvc6 = windows.NewLazySystemDLL("dhcpcsvc6.dll")
	procDhcpv6RequestPrefix = dhcpcsvc6.NewProc("Dhcpv6RequestPrefix")
)

// adapterName (LPWSTR), pclassId (DHCPV6CAPI_CLASSID* in/out), prefixleaseInfo (DHCPV6PrefixLeaseInformation* in/out), pdwTimeToWait (DWORD* out)
r1, _, err := procDhcpv6RequestPrefix.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(adapterName))),
	uintptr(pclassId),
	uintptr(prefixleaseInfo),
	uintptr(pdwTimeToWait),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function Dhcpv6RequestPrefix(
  adapterName: PWideChar;   // LPWSTR
  pclassId: Pointer;   // DHCPV6CAPI_CLASSID* in/out
  prefixleaseInfo: Pointer;   // DHCPV6PrefixLeaseInformation* in/out
  pdwTimeToWait: Pointer   // DWORD* out
): DWORD; stdcall;
  external 'dhcpcsvc6.dll' name 'Dhcpv6RequestPrefix';
result := DllCall("dhcpcsvc6\Dhcpv6RequestPrefix"
    , "WStr", adapterName   ; LPWSTR
    , "Ptr", pclassId   ; DHCPV6CAPI_CLASSID* in/out
    , "Ptr", prefixleaseInfo   ; DHCPV6PrefixLeaseInformation* in/out
    , "Ptr", pdwTimeToWait   ; DWORD* out
    , "UInt")   ; return: DWORD
●Dhcpv6RequestPrefix(adapterName, pclassId, prefixleaseInfo, pdwTimeToWait) = DLL("dhcpcsvc6.dll", "dword Dhcpv6RequestPrefix(char*, void*, void*, void*)")
# 呼び出し: Dhcpv6RequestPrefix(adapterName, pclassId, prefixleaseInfo, pdwTimeToWait)
# adapterName : LPWSTR -> "char*"
# pclassId : DHCPV6CAPI_CLASSID* in/out -> "void*"
# prefixleaseInfo : DHCPV6PrefixLeaseInformation* in/out -> "void*"
# pdwTimeToWait : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。