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

WnvRequestNotification

関数
WNVからの通知を非同期で要求する。
DLLwnvapi.dll呼出規約winapi対応OSwindowsserver2012

シグネチャ

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

DWORD WnvRequestNotification(
    HANDLE WnvHandle,
    WNV_NOTIFICATION_PARAM* NotificationParam,
    OVERLAPPED* Overlapped,
    DWORD* BytesTransferred
);

パラメーター

名前方向説明
WnvHandleHANDLEinWnvOpenで取得したネットワーク仮想化(WNV)ハンドル。
NotificationParamWNV_NOTIFICATION_PARAM*inout要求する通知種別等を指定するパラメータ構造体へのポインタ。
OverlappedOVERLAPPED*inout非同期I/Oに用いるOVERLAPPED構造体へのポインタ。同期時はNULL可。
BytesTransferredDWORD*inout転送されたバイト数を受け取る出力先。

戻り値の型: DWORD

各言語での呼び出し定義

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

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

WnvRequestNotification = ctypes.windll.wnvapi.WnvRequestNotification
WnvRequestNotification.restype = wintypes.DWORD
WnvRequestNotification.argtypes = [
    wintypes.HANDLE,  # WnvHandle : HANDLE
    ctypes.c_void_p,  # NotificationParam : WNV_NOTIFICATION_PARAM* in/out
    ctypes.c_void_p,  # Overlapped : OVERLAPPED* in/out
    ctypes.POINTER(wintypes.DWORD),  # BytesTransferred : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	wnvapi = windows.NewLazySystemDLL("wnvapi.dll")
	procWnvRequestNotification = wnvapi.NewProc("WnvRequestNotification")
)

// WnvHandle (HANDLE), NotificationParam (WNV_NOTIFICATION_PARAM* in/out), Overlapped (OVERLAPPED* in/out), BytesTransferred (DWORD* in/out)
r1, _, err := procWnvRequestNotification.Call(
	uintptr(WnvHandle),
	uintptr(NotificationParam),
	uintptr(Overlapped),
	uintptr(BytesTransferred),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function WnvRequestNotification(
  WnvHandle: THandle;   // HANDLE
  NotificationParam: Pointer;   // WNV_NOTIFICATION_PARAM* in/out
  Overlapped: Pointer;   // OVERLAPPED* in/out
  BytesTransferred: Pointer   // DWORD* in/out
): DWORD; stdcall;
  external 'wnvapi.dll' name 'WnvRequestNotification';
result := DllCall("wnvapi\WnvRequestNotification"
    , "Ptr", WnvHandle   ; HANDLE
    , "Ptr", NotificationParam   ; WNV_NOTIFICATION_PARAM* in/out
    , "Ptr", Overlapped   ; OVERLAPPED* in/out
    , "Ptr", BytesTransferred   ; DWORD* in/out
    , "UInt")   ; return: DWORD
●WnvRequestNotification(WnvHandle, NotificationParam, Overlapped, BytesTransferred) = DLL("wnvapi.dll", "dword WnvRequestNotification(void*, void*, void*, void*)")
# 呼び出し: WnvRequestNotification(WnvHandle, NotificationParam, Overlapped, BytesTransferred)
# WnvHandle : HANDLE -> "void*"
# NotificationParam : WNV_NOTIFICATION_PARAM* in/out -> "void*"
# Overlapped : OVERLAPPED* in/out -> "void*"
# BytesTransferred : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "wnvapi" fn WnvRequestNotification(
    WnvHandle: ?*anyopaque, // HANDLE
    NotificationParam: [*c]WNV_NOTIFICATION_PARAM, // WNV_NOTIFICATION_PARAM* in/out
    Overlapped: [*c]OVERLAPPED, // OVERLAPPED* in/out
    BytesTransferred: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) u32;
proc WnvRequestNotification(
    WnvHandle: pointer,  # HANDLE
    NotificationParam: ptr WNV_NOTIFICATION_PARAM,  # WNV_NOTIFICATION_PARAM* in/out
    Overlapped: ptr OVERLAPPED,  # OVERLAPPED* in/out
    BytesTransferred: ptr uint32  # DWORD* in/out
): uint32 {.importc: "WnvRequestNotification", stdcall, dynlib: "wnvapi.dll".}
pragma(lib, "wnvapi");
extern(Windows)
uint WnvRequestNotification(
    void* WnvHandle,   // HANDLE
    WNV_NOTIFICATION_PARAM* NotificationParam,   // WNV_NOTIFICATION_PARAM* in/out
    OVERLAPPED* Overlapped,   // OVERLAPPED* in/out
    uint* BytesTransferred   // DWORD* in/out
);
ccall((:WnvRequestNotification, "wnvapi.dll"), stdcall, UInt32,
      (Ptr{Cvoid}, Ptr{WNV_NOTIFICATION_PARAM}, Ptr{OVERLAPPED}, Ptr{UInt32}),
      WnvHandle, NotificationParam, Overlapped, BytesTransferred)
# WnvHandle : HANDLE -> Ptr{Cvoid}
# NotificationParam : WNV_NOTIFICATION_PARAM* in/out -> Ptr{WNV_NOTIFICATION_PARAM}
# Overlapped : OVERLAPPED* in/out -> Ptr{OVERLAPPED}
# BytesTransferred : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t WnvRequestNotification(
    void* WnvHandle,
    void* NotificationParam,
    void* Overlapped,
    uint32_t* BytesTransferred);
]]
local wnvapi = ffi.load("wnvapi")
-- wnvapi.WnvRequestNotification(WnvHandle, NotificationParam, Overlapped, BytesTransferred)
-- WnvHandle : HANDLE
-- NotificationParam : WNV_NOTIFICATION_PARAM* in/out
-- Overlapped : OVERLAPPED* in/out
-- BytesTransferred : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('wnvapi.dll');
const WnvRequestNotification = lib.func('__stdcall', 'WnvRequestNotification', 'uint32_t', ['void *', 'void *', 'void *', 'uint32_t *']);
// WnvRequestNotification(WnvHandle, NotificationParam, Overlapped, BytesTransferred)
// WnvHandle : HANDLE -> 'void *'
// NotificationParam : WNV_NOTIFICATION_PARAM* in/out -> 'void *'
// Overlapped : OVERLAPPED* in/out -> 'void *'
// BytesTransferred : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("wnvapi.dll", {
  WnvRequestNotification: { parameters: ["pointer", "pointer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.WnvRequestNotification(WnvHandle, NotificationParam, Overlapped, BytesTransferred)
// WnvHandle : HANDLE -> "pointer"
// NotificationParam : WNV_NOTIFICATION_PARAM* in/out -> "pointer"
// Overlapped : OVERLAPPED* in/out -> "pointer"
// BytesTransferred : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t WnvRequestNotification(
    void* WnvHandle,
    void* NotificationParam,
    void* Overlapped,
    uint32_t* BytesTransferred);
C, "wnvapi.dll");
// $ffi->WnvRequestNotification(WnvHandle, NotificationParam, Overlapped, BytesTransferred);
// WnvHandle : HANDLE
// NotificationParam : WNV_NOTIFICATION_PARAM* in/out
// Overlapped : OVERLAPPED* in/out
// BytesTransferred : DWORD* 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 Wnvapi extends StdCallLibrary {
    Wnvapi INSTANCE = Native.load("wnvapi", Wnvapi.class);
    int WnvRequestNotification(
        Pointer WnvHandle,   // HANDLE
        Pointer NotificationParam,   // WNV_NOTIFICATION_PARAM* in/out
        Pointer Overlapped,   // OVERLAPPED* in/out
        IntByReference BytesTransferred   // DWORD* in/out
    );
}
@[Link("wnvapi")]
lib Libwnvapi
  fun WnvRequestNotification = WnvRequestNotification(
    WnvHandle : Void*,   # HANDLE
    NotificationParam : WNV_NOTIFICATION_PARAM*,   # WNV_NOTIFICATION_PARAM* in/out
    Overlapped : OVERLAPPED*,   # OVERLAPPED* in/out
    BytesTransferred : UInt32*   # DWORD* 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 WnvRequestNotificationNative = Uint32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Uint32>);
typedef WnvRequestNotificationDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Uint32>);
final WnvRequestNotification = DynamicLibrary.open('wnvapi.dll')
    .lookupFunction<WnvRequestNotificationNative, WnvRequestNotificationDart>('WnvRequestNotification');
// WnvHandle : HANDLE -> Pointer<Void>
// NotificationParam : WNV_NOTIFICATION_PARAM* in/out -> Pointer<Void>
// Overlapped : OVERLAPPED* in/out -> Pointer<Void>
// BytesTransferred : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WnvRequestNotification(
  WnvHandle: THandle;   // HANDLE
  NotificationParam: Pointer;   // WNV_NOTIFICATION_PARAM* in/out
  Overlapped: Pointer;   // OVERLAPPED* in/out
  BytesTransferred: Pointer   // DWORD* in/out
): DWORD; stdcall;
  external 'wnvapi.dll' name 'WnvRequestNotification';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WnvRequestNotification"
  c_WnvRequestNotification :: Ptr () -> Ptr () -> Ptr () -> Ptr Word32 -> IO Word32
-- WnvHandle : HANDLE -> Ptr ()
-- NotificationParam : WNV_NOTIFICATION_PARAM* in/out -> Ptr ()
-- Overlapped : OVERLAPPED* in/out -> Ptr ()
-- BytesTransferred : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wnvrequestnotification =
  foreign "WnvRequestNotification"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr uint32_t) @-> returning uint32_t)
(* WnvHandle : HANDLE -> (ptr void) *)
(* NotificationParam : WNV_NOTIFICATION_PARAM* in/out -> (ptr void) *)
(* Overlapped : OVERLAPPED* in/out -> (ptr void) *)
(* BytesTransferred : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wnvapi (t "wnvapi.dll"))
(cffi:use-foreign-library wnvapi)

(cffi:defcfun ("WnvRequestNotification" wnv-request-notification :convention :stdcall) :uint32
  (wnv-handle :pointer)   ; HANDLE
  (notification-param :pointer)   ; WNV_NOTIFICATION_PARAM* in/out
  (overlapped :pointer)   ; OVERLAPPED* in/out
  (bytes-transferred :pointer))   ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WnvRequestNotification = Win32::API::More->new('wnvapi',
    'DWORD WnvRequestNotification(HANDLE WnvHandle, LPVOID NotificationParam, LPVOID Overlapped, LPVOID BytesTransferred)');
# my $ret = $WnvRequestNotification->Call($WnvHandle, $NotificationParam, $Overlapped, $BytesTransferred);
# WnvHandle : HANDLE -> HANDLE
# NotificationParam : WNV_NOTIFICATION_PARAM* in/out -> LPVOID
# Overlapped : OVERLAPPED* in/out -> LPVOID
# BytesTransferred : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型