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

Dhcpv6RenewPrefix

関数
DHCPv6で委任されたプレフィックスのリースを更新する。
DLLdhcpcsvc6.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

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

パラメーター

名前方向説明
adapterNameLPWSTRinプレフィックスを更新する対象アダプタ名(Unicode)へのポインタ。
pclassIdDHCPV6CAPI_CLASSID*inoutDHCPv6クラスIDを格納したDHCPV6CAPI_CLASSID構造体へのポインタ。NULL可。
prefixleaseInfoDHCPV6PrefixLeaseInformation*inout更新対象/更新後のプレフィックスリース情報を保持するDHCPV6PrefixLeaseInformation構造体へのポインタ。
pdwTimeToWaitDWORD*out次の更新までの待機時間(秒)を受け取るDWORDへのポインタ。
bValidatePrefixDWORDinプレフィックスの妥当性検証を行うか指定するDWORD。非0で検証する。

戻り値の型: DWORD

各言語での呼び出し定義

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

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

Dhcpv6RenewPrefix = ctypes.windll.dhcpcsvc6.Dhcpv6RenewPrefix
Dhcpv6RenewPrefix.restype = wintypes.DWORD
Dhcpv6RenewPrefix.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
    wintypes.DWORD,  # bValidatePrefix : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	dhcpcsvc6 = windows.NewLazySystemDLL("dhcpcsvc6.dll")
	procDhcpv6RenewPrefix = dhcpcsvc6.NewProc("Dhcpv6RenewPrefix")
)

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

extern "dhcpcsvc6" fn Dhcpv6RenewPrefix(
    adapterName: [*c]const u16, // LPWSTR
    pclassId: [*c]DHCPV6CAPI_CLASSID, // DHCPV6CAPI_CLASSID* in/out
    prefixleaseInfo: [*c]DHCPV6PrefixLeaseInformation, // DHCPV6PrefixLeaseInformation* in/out
    pdwTimeToWait: [*c]u32, // DWORD* out
    bValidatePrefix: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;
proc Dhcpv6RenewPrefix(
    adapterName: WideCString,  # LPWSTR
    pclassId: ptr DHCPV6CAPI_CLASSID,  # DHCPV6CAPI_CLASSID* in/out
    prefixleaseInfo: ptr DHCPV6PrefixLeaseInformation,  # DHCPV6PrefixLeaseInformation* in/out
    pdwTimeToWait: ptr uint32,  # DWORD* out
    bValidatePrefix: uint32  # DWORD
): uint32 {.importc: "Dhcpv6RenewPrefix", stdcall, dynlib: "dhcpcsvc6.dll".}
pragma(lib, "dhcpcsvc6");
extern(Windows)
uint Dhcpv6RenewPrefix(
    const(wchar)* adapterName,   // LPWSTR
    DHCPV6CAPI_CLASSID* pclassId,   // DHCPV6CAPI_CLASSID* in/out
    DHCPV6PrefixLeaseInformation* prefixleaseInfo,   // DHCPV6PrefixLeaseInformation* in/out
    uint* pdwTimeToWait,   // DWORD* out
    uint bValidatePrefix   // DWORD
);
ccall((:Dhcpv6RenewPrefix, "dhcpcsvc6.dll"), stdcall, UInt32,
      (Cwstring, Ptr{DHCPV6CAPI_CLASSID}, Ptr{DHCPV6PrefixLeaseInformation}, Ptr{UInt32}, UInt32),
      adapterName, pclassId, prefixleaseInfo, pdwTimeToWait, bValidatePrefix)
# adapterName : LPWSTR -> Cwstring
# pclassId : DHCPV6CAPI_CLASSID* in/out -> Ptr{DHCPV6CAPI_CLASSID}
# prefixleaseInfo : DHCPV6PrefixLeaseInformation* in/out -> Ptr{DHCPV6PrefixLeaseInformation}
# pdwTimeToWait : DWORD* out -> Ptr{UInt32}
# bValidatePrefix : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t Dhcpv6RenewPrefix(
    const uint16_t* adapterName,
    void* pclassId,
    void* prefixleaseInfo,
    uint32_t* pdwTimeToWait,
    uint32_t bValidatePrefix);
]]
local dhcpcsvc6 = ffi.load("dhcpcsvc6")
-- dhcpcsvc6.Dhcpv6RenewPrefix(adapterName, pclassId, prefixleaseInfo, pdwTimeToWait, bValidatePrefix)
-- adapterName : LPWSTR
-- pclassId : DHCPV6CAPI_CLASSID* in/out
-- prefixleaseInfo : DHCPV6PrefixLeaseInformation* in/out
-- pdwTimeToWait : DWORD* out
-- bValidatePrefix : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('dhcpcsvc6.dll');
const Dhcpv6RenewPrefix = lib.func('__stdcall', 'Dhcpv6RenewPrefix', 'uint32_t', ['str16', 'void *', 'void *', 'uint32_t *', 'uint32_t']);
// Dhcpv6RenewPrefix(adapterName, pclassId, prefixleaseInfo, pdwTimeToWait, bValidatePrefix)
// adapterName : LPWSTR -> 'str16'
// pclassId : DHCPV6CAPI_CLASSID* in/out -> 'void *'
// prefixleaseInfo : DHCPV6PrefixLeaseInformation* in/out -> 'void *'
// pdwTimeToWait : DWORD* out -> 'uint32_t *'
// bValidatePrefix : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("dhcpcsvc6.dll", {
  Dhcpv6RenewPrefix: { parameters: ["buffer", "pointer", "pointer", "pointer", "u32"], result: "u32" },
});
// lib.symbols.Dhcpv6RenewPrefix(adapterName, pclassId, prefixleaseInfo, pdwTimeToWait, bValidatePrefix)
// adapterName : LPWSTR -> "buffer"
// pclassId : DHCPV6CAPI_CLASSID* in/out -> "pointer"
// prefixleaseInfo : DHCPV6PrefixLeaseInformation* in/out -> "pointer"
// pdwTimeToWait : DWORD* out -> "pointer"
// bValidatePrefix : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t Dhcpv6RenewPrefix(
    const uint16_t* adapterName,
    void* pclassId,
    void* prefixleaseInfo,
    uint32_t* pdwTimeToWait,
    uint32_t bValidatePrefix);
C, "dhcpcsvc6.dll");
// $ffi->Dhcpv6RenewPrefix(adapterName, pclassId, prefixleaseInfo, pdwTimeToWait, bValidatePrefix);
// adapterName : LPWSTR
// pclassId : DHCPV6CAPI_CLASSID* in/out
// prefixleaseInfo : DHCPV6PrefixLeaseInformation* in/out
// pdwTimeToWait : DWORD* out
// bValidatePrefix : DWORD
// 構造体/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 Dhcpcsvc6 extends StdCallLibrary {
    Dhcpcsvc6 INSTANCE = Native.load("dhcpcsvc6", Dhcpcsvc6.class);
    int Dhcpv6RenewPrefix(
        WString adapterName,   // LPWSTR
        Pointer pclassId,   // DHCPV6CAPI_CLASSID* in/out
        Pointer prefixleaseInfo,   // DHCPV6PrefixLeaseInformation* in/out
        IntByReference pdwTimeToWait,   // DWORD* out
        int bValidatePrefix   // DWORD
    );
}
@[Link("dhcpcsvc6")]
lib Libdhcpcsvc6
  fun Dhcpv6RenewPrefix = Dhcpv6RenewPrefix(
    adapterName : UInt16*,   # LPWSTR
    pclassId : DHCPV6CAPI_CLASSID*,   # DHCPV6CAPI_CLASSID* in/out
    prefixleaseInfo : DHCPV6PrefixLeaseInformation*,   # DHCPV6PrefixLeaseInformation* in/out
    pdwTimeToWait : UInt32*,   # DWORD* out
    bValidatePrefix : UInt32   # DWORD
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef Dhcpv6RenewPrefixNative = Uint32 Function(Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Pointer<Uint32>, Uint32);
typedef Dhcpv6RenewPrefixDart = int Function(Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Pointer<Uint32>, int);
final Dhcpv6RenewPrefix = DynamicLibrary.open('dhcpcsvc6.dll')
    .lookupFunction<Dhcpv6RenewPrefixNative, Dhcpv6RenewPrefixDart>('Dhcpv6RenewPrefix');
// adapterName : LPWSTR -> Pointer<Utf16>
// pclassId : DHCPV6CAPI_CLASSID* in/out -> Pointer<Void>
// prefixleaseInfo : DHCPV6PrefixLeaseInformation* in/out -> Pointer<Void>
// pdwTimeToWait : DWORD* out -> Pointer<Uint32>
// bValidatePrefix : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function Dhcpv6RenewPrefix(
  adapterName: PWideChar;   // LPWSTR
  pclassId: Pointer;   // DHCPV6CAPI_CLASSID* in/out
  prefixleaseInfo: Pointer;   // DHCPV6PrefixLeaseInformation* in/out
  pdwTimeToWait: Pointer;   // DWORD* out
  bValidatePrefix: DWORD   // DWORD
): DWORD; stdcall;
  external 'dhcpcsvc6.dll' name 'Dhcpv6RenewPrefix';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "Dhcpv6RenewPrefix"
  c_Dhcpv6RenewPrefix :: CWString -> Ptr () -> Ptr () -> Ptr Word32 -> Word32 -> IO Word32
-- adapterName : LPWSTR -> CWString
-- pclassId : DHCPV6CAPI_CLASSID* in/out -> Ptr ()
-- prefixleaseInfo : DHCPV6PrefixLeaseInformation* in/out -> Ptr ()
-- pdwTimeToWait : DWORD* out -> Ptr Word32
-- bValidatePrefix : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let dhcpv6renewprefix =
  foreign "Dhcpv6RenewPrefix"
    ((ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> (ptr uint32_t) @-> uint32_t @-> returning uint32_t)
(* adapterName : LPWSTR -> (ptr uint16_t) *)
(* pclassId : DHCPV6CAPI_CLASSID* in/out -> (ptr void) *)
(* prefixleaseInfo : DHCPV6PrefixLeaseInformation* in/out -> (ptr void) *)
(* pdwTimeToWait : DWORD* out -> (ptr uint32_t) *)
(* bValidatePrefix : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library dhcpcsvc6 (t "dhcpcsvc6.dll"))
(cffi:use-foreign-library dhcpcsvc6)

(cffi:defcfun ("Dhcpv6RenewPrefix" dhcpv6-renew-prefix :convention :stdcall) :uint32
  (adapter-name (:string :encoding :utf-16le))   ; LPWSTR
  (pclass-id :pointer)   ; DHCPV6CAPI_CLASSID* in/out
  (prefixlease-info :pointer)   ; DHCPV6PrefixLeaseInformation* in/out
  (pdw-time-to-wait :pointer)   ; DWORD* out
  (b-validate-prefix :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $Dhcpv6RenewPrefix = Win32::API::More->new('dhcpcsvc6',
    'DWORD Dhcpv6RenewPrefix(LPCWSTR adapterName, LPVOID pclassId, LPVOID prefixleaseInfo, LPVOID pdwTimeToWait, DWORD bValidatePrefix)');
# my $ret = $Dhcpv6RenewPrefix->Call($adapterName, $pclassId, $prefixleaseInfo, $pdwTimeToWait, $bValidatePrefix);
# adapterName : LPWSTR -> LPCWSTR
# pclassId : DHCPV6CAPI_CLASSID* in/out -> LPVOID
# prefixleaseInfo : DHCPV6PrefixLeaseInformation* in/out -> LPVOID
# pdwTimeToWait : DWORD* out -> LPVOID
# bValidatePrefix : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型