ホーム › System.Hypervisor › WHvCreateNotificationPort
WHvCreateNotificationPort
関数パーティションに通知ポートを作成する。
シグネチャ
// WinHvPlatform.dll
#include <windows.h>
HRESULT WHvCreateNotificationPort(
WHV_PARTITION_HANDLE Partition,
const WHV_NOTIFICATION_PORT_PARAMETERS* Parameters,
HANDLE EventHandle,
void** PortHandle
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Partition | WHV_PARTITION_HANDLE | in | 対象パーティションのハンドルを指定する。 |
| Parameters | WHV_NOTIFICATION_PORT_PARAMETERS* | in | 通知ポートの種類や設定を記述するパラメータ構造体へのポインタ。 |
| EventHandle | HANDLE | in | 通知発生時にシグナルされるイベントオブジェクトのハンドルを指定する。 |
| PortHandle | void** | out | 作成された通知ポートのハンドルを受け取る出力ポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// WinHvPlatform.dll
#include <windows.h>
HRESULT WHvCreateNotificationPort(
WHV_PARTITION_HANDLE Partition,
const WHV_NOTIFICATION_PORT_PARAMETERS* Parameters,
HANDLE EventHandle,
void** PortHandle
);[DllImport("WinHvPlatform.dll", ExactSpelling = true)]
static extern int WHvCreateNotificationPort(
IntPtr Partition, // WHV_PARTITION_HANDLE
IntPtr Parameters, // WHV_NOTIFICATION_PORT_PARAMETERS*
IntPtr EventHandle, // HANDLE
IntPtr PortHandle // void** out
);<DllImport("WinHvPlatform.dll", ExactSpelling:=True)>
Public Shared Function WHvCreateNotificationPort(
Partition As IntPtr, ' WHV_PARTITION_HANDLE
Parameters As IntPtr, ' WHV_NOTIFICATION_PORT_PARAMETERS*
EventHandle As IntPtr, ' HANDLE
PortHandle As IntPtr ' void** out
) As Integer
End Function' Partition : WHV_PARTITION_HANDLE
' Parameters : WHV_NOTIFICATION_PORT_PARAMETERS*
' EventHandle : HANDLE
' PortHandle : void** out
Declare PtrSafe Function WHvCreateNotificationPort Lib "winhvplatform" ( _
ByVal Partition As LongPtr, _
ByVal Parameters As LongPtr, _
ByVal EventHandle As LongPtr, _
ByVal PortHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WHvCreateNotificationPort = ctypes.windll.winhvplatform.WHvCreateNotificationPort
WHvCreateNotificationPort.restype = ctypes.c_int
WHvCreateNotificationPort.argtypes = [
ctypes.c_ssize_t, # Partition : WHV_PARTITION_HANDLE
ctypes.c_void_p, # Parameters : WHV_NOTIFICATION_PORT_PARAMETERS*
wintypes.HANDLE, # EventHandle : HANDLE
ctypes.c_void_p, # PortHandle : void** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WinHvPlatform.dll')
WHvCreateNotificationPort = Fiddle::Function.new(
lib['WHvCreateNotificationPort'],
[
Fiddle::TYPE_INTPTR_T, # Partition : WHV_PARTITION_HANDLE
Fiddle::TYPE_VOIDP, # Parameters : WHV_NOTIFICATION_PORT_PARAMETERS*
Fiddle::TYPE_VOIDP, # EventHandle : HANDLE
Fiddle::TYPE_VOIDP, # PortHandle : void** out
],
Fiddle::TYPE_INT)#[link(name = "winhvplatform")]
extern "system" {
fn WHvCreateNotificationPort(
Partition: isize, // WHV_PARTITION_HANDLE
Parameters: *const WHV_NOTIFICATION_PORT_PARAMETERS, // WHV_NOTIFICATION_PORT_PARAMETERS*
EventHandle: *mut core::ffi::c_void, // HANDLE
PortHandle: *mut *mut () // void** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WinHvPlatform.dll")]
public static extern int WHvCreateNotificationPort(IntPtr Partition, IntPtr Parameters, IntPtr EventHandle, IntPtr PortHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WinHvPlatform_WHvCreateNotificationPort' -Namespace Win32 -PassThru
# $api::WHvCreateNotificationPort(Partition, Parameters, EventHandle, PortHandle)#uselib "WinHvPlatform.dll"
#func global WHvCreateNotificationPort "WHvCreateNotificationPort" sptr, sptr, sptr, sptr
; WHvCreateNotificationPort Partition, varptr(Parameters), EventHandle, PortHandle ; 戻り値は stat
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; Parameters : WHV_NOTIFICATION_PORT_PARAMETERS* -> "sptr"
; EventHandle : HANDLE -> "sptr"
; PortHandle : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WinHvPlatform.dll" #cfunc global WHvCreateNotificationPort "WHvCreateNotificationPort" sptr, var, sptr, sptr ; res = WHvCreateNotificationPort(Partition, Parameters, EventHandle, PortHandle) ; Partition : WHV_PARTITION_HANDLE -> "sptr" ; Parameters : WHV_NOTIFICATION_PORT_PARAMETERS* -> "var" ; EventHandle : HANDLE -> "sptr" ; PortHandle : void** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WinHvPlatform.dll" #cfunc global WHvCreateNotificationPort "WHvCreateNotificationPort" sptr, sptr, sptr, sptr ; res = WHvCreateNotificationPort(Partition, varptr(Parameters), EventHandle, PortHandle) ; Partition : WHV_PARTITION_HANDLE -> "sptr" ; Parameters : WHV_NOTIFICATION_PORT_PARAMETERS* -> "sptr" ; EventHandle : HANDLE -> "sptr" ; PortHandle : void** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT WHvCreateNotificationPort(WHV_PARTITION_HANDLE Partition, WHV_NOTIFICATION_PORT_PARAMETERS* Parameters, HANDLE EventHandle, void** PortHandle) #uselib "WinHvPlatform.dll" #cfunc global WHvCreateNotificationPort "WHvCreateNotificationPort" intptr, var, intptr, intptr ; res = WHvCreateNotificationPort(Partition, Parameters, EventHandle, PortHandle) ; Partition : WHV_PARTITION_HANDLE -> "intptr" ; Parameters : WHV_NOTIFICATION_PORT_PARAMETERS* -> "var" ; EventHandle : HANDLE -> "intptr" ; PortHandle : void** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WHvCreateNotificationPort(WHV_PARTITION_HANDLE Partition, WHV_NOTIFICATION_PORT_PARAMETERS* Parameters, HANDLE EventHandle, void** PortHandle) #uselib "WinHvPlatform.dll" #cfunc global WHvCreateNotificationPort "WHvCreateNotificationPort" intptr, intptr, intptr, intptr ; res = WHvCreateNotificationPort(Partition, varptr(Parameters), EventHandle, PortHandle) ; Partition : WHV_PARTITION_HANDLE -> "intptr" ; Parameters : WHV_NOTIFICATION_PORT_PARAMETERS* -> "intptr" ; EventHandle : HANDLE -> "intptr" ; PortHandle : void** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winhvplatform = windows.NewLazySystemDLL("WinHvPlatform.dll")
procWHvCreateNotificationPort = winhvplatform.NewProc("WHvCreateNotificationPort")
)
// Partition (WHV_PARTITION_HANDLE), Parameters (WHV_NOTIFICATION_PORT_PARAMETERS*), EventHandle (HANDLE), PortHandle (void** out)
r1, _, err := procWHvCreateNotificationPort.Call(
uintptr(Partition),
uintptr(Parameters),
uintptr(EventHandle),
uintptr(PortHandle),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WHvCreateNotificationPort(
Partition: NativeInt; // WHV_PARTITION_HANDLE
Parameters: Pointer; // WHV_NOTIFICATION_PORT_PARAMETERS*
EventHandle: THandle; // HANDLE
PortHandle: Pointer // void** out
): Integer; stdcall;
external 'WinHvPlatform.dll' name 'WHvCreateNotificationPort';result := DllCall("WinHvPlatform\WHvCreateNotificationPort"
, "Ptr", Partition ; WHV_PARTITION_HANDLE
, "Ptr", Parameters ; WHV_NOTIFICATION_PORT_PARAMETERS*
, "Ptr", EventHandle ; HANDLE
, "Ptr", PortHandle ; void** out
, "Int") ; return: HRESULT●WHvCreateNotificationPort(Partition, Parameters, EventHandle, PortHandle) = DLL("WinHvPlatform.dll", "int WHvCreateNotificationPort(int, void*, void*, void*)")
# 呼び出し: WHvCreateNotificationPort(Partition, Parameters, EventHandle, PortHandle)
# Partition : WHV_PARTITION_HANDLE -> "int"
# Parameters : WHV_NOTIFICATION_PORT_PARAMETERS* -> "void*"
# EventHandle : HANDLE -> "void*"
# PortHandle : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "winhvplatform" fn WHvCreateNotificationPort(
Partition: isize, // WHV_PARTITION_HANDLE
Parameters: [*c]WHV_NOTIFICATION_PORT_PARAMETERS, // WHV_NOTIFICATION_PORT_PARAMETERS*
EventHandle: ?*anyopaque, // HANDLE
PortHandle: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;proc WHvCreateNotificationPort(
Partition: int, # WHV_PARTITION_HANDLE
Parameters: ptr WHV_NOTIFICATION_PORT_PARAMETERS, # WHV_NOTIFICATION_PORT_PARAMETERS*
EventHandle: pointer, # HANDLE
PortHandle: pointer # void** out
): int32 {.importc: "WHvCreateNotificationPort", stdcall, dynlib: "WinHvPlatform.dll".}pragma(lib, "winhvplatform");
extern(Windows)
int WHvCreateNotificationPort(
ptrdiff_t Partition, // WHV_PARTITION_HANDLE
WHV_NOTIFICATION_PORT_PARAMETERS* Parameters, // WHV_NOTIFICATION_PORT_PARAMETERS*
void* EventHandle, // HANDLE
void** PortHandle // void** out
);ccall((:WHvCreateNotificationPort, "WinHvPlatform.dll"), stdcall, Int32,
(Int, Ptr{WHV_NOTIFICATION_PORT_PARAMETERS}, Ptr{Cvoid}, Ptr{Cvoid}),
Partition, Parameters, EventHandle, PortHandle)
# Partition : WHV_PARTITION_HANDLE -> Int
# Parameters : WHV_NOTIFICATION_PORT_PARAMETERS* -> Ptr{WHV_NOTIFICATION_PORT_PARAMETERS}
# EventHandle : HANDLE -> Ptr{Cvoid}
# PortHandle : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WHvCreateNotificationPort(
intptr_t Partition,
void* Parameters,
void* EventHandle,
void** PortHandle);
]]
local winhvplatform = ffi.load("winhvplatform")
-- winhvplatform.WHvCreateNotificationPort(Partition, Parameters, EventHandle, PortHandle)
-- Partition : WHV_PARTITION_HANDLE
-- Parameters : WHV_NOTIFICATION_PORT_PARAMETERS*
-- EventHandle : HANDLE
-- PortHandle : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WinHvPlatform.dll');
const WHvCreateNotificationPort = lib.func('__stdcall', 'WHvCreateNotificationPort', 'int32_t', ['intptr_t', 'void *', 'void *', 'void *']);
// WHvCreateNotificationPort(Partition, Parameters, EventHandle, PortHandle)
// Partition : WHV_PARTITION_HANDLE -> 'intptr_t'
// Parameters : WHV_NOTIFICATION_PORT_PARAMETERS* -> 'void *'
// EventHandle : HANDLE -> 'void *'
// PortHandle : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WinHvPlatform.dll", {
WHvCreateNotificationPort: { parameters: ["isize", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WHvCreateNotificationPort(Partition, Parameters, EventHandle, PortHandle)
// Partition : WHV_PARTITION_HANDLE -> "isize"
// Parameters : WHV_NOTIFICATION_PORT_PARAMETERS* -> "pointer"
// EventHandle : HANDLE -> "pointer"
// PortHandle : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WHvCreateNotificationPort(
intptr_t Partition,
void* Parameters,
void* EventHandle,
void** PortHandle);
C, "WinHvPlatform.dll");
// $ffi->WHvCreateNotificationPort(Partition, Parameters, EventHandle, PortHandle);
// Partition : WHV_PARTITION_HANDLE
// Parameters : WHV_NOTIFICATION_PORT_PARAMETERS*
// EventHandle : HANDLE
// PortHandle : void** 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 Winhvplatform extends StdCallLibrary {
Winhvplatform INSTANCE = Native.load("winhvplatform", Winhvplatform.class);
int WHvCreateNotificationPort(
long Partition, // WHV_PARTITION_HANDLE
Pointer Parameters, // WHV_NOTIFICATION_PORT_PARAMETERS*
Pointer EventHandle, // HANDLE
Pointer PortHandle // void** out
);
}@[Link("winhvplatform")]
lib LibWinHvPlatform
fun WHvCreateNotificationPort = WHvCreateNotificationPort(
Partition : LibC::SSizeT, # WHV_PARTITION_HANDLE
Parameters : WHV_NOTIFICATION_PORT_PARAMETERS*, # WHV_NOTIFICATION_PORT_PARAMETERS*
EventHandle : Void*, # HANDLE
PortHandle : Void** # void** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WHvCreateNotificationPortNative = Int32 Function(IntPtr, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef WHvCreateNotificationPortDart = int Function(int, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final WHvCreateNotificationPort = DynamicLibrary.open('WinHvPlatform.dll')
.lookupFunction<WHvCreateNotificationPortNative, WHvCreateNotificationPortDart>('WHvCreateNotificationPort');
// Partition : WHV_PARTITION_HANDLE -> IntPtr
// Parameters : WHV_NOTIFICATION_PORT_PARAMETERS* -> Pointer<Void>
// EventHandle : HANDLE -> Pointer<Void>
// PortHandle : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WHvCreateNotificationPort(
Partition: NativeInt; // WHV_PARTITION_HANDLE
Parameters: Pointer; // WHV_NOTIFICATION_PORT_PARAMETERS*
EventHandle: THandle; // HANDLE
PortHandle: Pointer // void** out
): Integer; stdcall;
external 'WinHvPlatform.dll' name 'WHvCreateNotificationPort';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WHvCreateNotificationPort"
c_WHvCreateNotificationPort :: CIntPtr -> Ptr () -> Ptr () -> Ptr () -> IO Int32
-- Partition : WHV_PARTITION_HANDLE -> CIntPtr
-- Parameters : WHV_NOTIFICATION_PORT_PARAMETERS* -> Ptr ()
-- EventHandle : HANDLE -> Ptr ()
-- PortHandle : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let whvcreatenotificationport =
foreign "WHvCreateNotificationPort"
(intptr_t @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* Partition : WHV_PARTITION_HANDLE -> intptr_t *)
(* Parameters : WHV_NOTIFICATION_PORT_PARAMETERS* -> (ptr void) *)
(* EventHandle : HANDLE -> (ptr void) *)
(* PortHandle : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library winhvplatform (t "WinHvPlatform.dll"))
(cffi:use-foreign-library winhvplatform)
(cffi:defcfun ("WHvCreateNotificationPort" whv-create-notification-port :convention :stdcall) :int32
(partition :int64) ; WHV_PARTITION_HANDLE
(parameters :pointer) ; WHV_NOTIFICATION_PORT_PARAMETERS*
(event-handle :pointer) ; HANDLE
(port-handle :pointer)) ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WHvCreateNotificationPort = Win32::API::More->new('WinHvPlatform',
'int WHvCreateNotificationPort(LPARAM Partition, LPVOID Parameters, HANDLE EventHandle, LPVOID PortHandle)');
# my $ret = $WHvCreateNotificationPort->Call($Partition, $Parameters, $EventHandle, $PortHandle);
# Partition : WHV_PARTITION_HANDLE -> LPARAM
# Parameters : WHV_NOTIFICATION_PORT_PARAMETERS* -> LPVOID
# EventHandle : HANDLE -> HANDLE
# PortHandle : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。