ホーム › NetworkManagement.P2P › PeerGraphRegisterEvent
PeerGraphRegisterEvent
関数ピアグラフのイベント通知を登録する。
シグネチャ
// P2PGRAPH.dll
#include <windows.h>
HRESULT PeerGraphRegisterEvent(
void* hGraph,
HANDLE hEvent,
DWORD cEventRegistrations,
PEER_GRAPH_EVENT_REGISTRATION* pEventRegistrations,
void** phPeerEvent
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hGraph | void* | in | イベントを登録する対象のグラフを表すハンドル。 |
| hEvent | HANDLE | in | イベント発生時にシグナル状態になるイベントオブジェクトのハンドル。NULL可。 |
| cEventRegistrations | DWORD | in | pEventRegistrations配列に含まれる登録エントリ数。 |
| pEventRegistrations | PEER_GRAPH_EVENT_REGISTRATION* | in | 登録するイベント種別を記述したPEER_GRAPH_EVENT_REGISTRATION配列へのポインター。 |
| phPeerEvent | void** | out | 登録結果として得られるイベントハンドルを受け取る出力ポインター。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// P2PGRAPH.dll
#include <windows.h>
HRESULT PeerGraphRegisterEvent(
void* hGraph,
HANDLE hEvent,
DWORD cEventRegistrations,
PEER_GRAPH_EVENT_REGISTRATION* pEventRegistrations,
void** phPeerEvent
);[DllImport("P2PGRAPH.dll", ExactSpelling = true)]
static extern int PeerGraphRegisterEvent(
IntPtr hGraph, // void*
IntPtr hEvent, // HANDLE
uint cEventRegistrations, // DWORD
IntPtr pEventRegistrations, // PEER_GRAPH_EVENT_REGISTRATION*
IntPtr phPeerEvent // void** out
);<DllImport("P2PGRAPH.dll", ExactSpelling:=True)>
Public Shared Function PeerGraphRegisterEvent(
hGraph As IntPtr, ' void*
hEvent As IntPtr, ' HANDLE
cEventRegistrations As UInteger, ' DWORD
pEventRegistrations As IntPtr, ' PEER_GRAPH_EVENT_REGISTRATION*
phPeerEvent As IntPtr ' void** out
) As Integer
End Function' hGraph : void*
' hEvent : HANDLE
' cEventRegistrations : DWORD
' pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION*
' phPeerEvent : void** out
Declare PtrSafe Function PeerGraphRegisterEvent Lib "p2pgraph" ( _
ByVal hGraph As LongPtr, _
ByVal hEvent As LongPtr, _
ByVal cEventRegistrations As Long, _
ByVal pEventRegistrations As LongPtr, _
ByVal phPeerEvent As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PeerGraphRegisterEvent = ctypes.windll.p2pgraph.PeerGraphRegisterEvent
PeerGraphRegisterEvent.restype = ctypes.c_int
PeerGraphRegisterEvent.argtypes = [
ctypes.POINTER(None), # hGraph : void*
wintypes.HANDLE, # hEvent : HANDLE
wintypes.DWORD, # cEventRegistrations : DWORD
ctypes.c_void_p, # pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION*
ctypes.c_void_p, # phPeerEvent : void** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('P2PGRAPH.dll')
PeerGraphRegisterEvent = Fiddle::Function.new(
lib['PeerGraphRegisterEvent'],
[
Fiddle::TYPE_VOIDP, # hGraph : void*
Fiddle::TYPE_VOIDP, # hEvent : HANDLE
-Fiddle::TYPE_INT, # cEventRegistrations : DWORD
Fiddle::TYPE_VOIDP, # pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION*
Fiddle::TYPE_VOIDP, # phPeerEvent : void** out
],
Fiddle::TYPE_INT)#[link(name = "p2pgraph")]
extern "system" {
fn PeerGraphRegisterEvent(
hGraph: *mut (), // void*
hEvent: *mut core::ffi::c_void, // HANDLE
cEventRegistrations: u32, // DWORD
pEventRegistrations: *mut PEER_GRAPH_EVENT_REGISTRATION, // PEER_GRAPH_EVENT_REGISTRATION*
phPeerEvent: *mut *mut () // void** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("P2PGRAPH.dll")]
public static extern int PeerGraphRegisterEvent(IntPtr hGraph, IntPtr hEvent, uint cEventRegistrations, IntPtr pEventRegistrations, IntPtr phPeerEvent);
"@
$api = Add-Type -MemberDefinition $sig -Name 'P2PGRAPH_PeerGraphRegisterEvent' -Namespace Win32 -PassThru
# $api::PeerGraphRegisterEvent(hGraph, hEvent, cEventRegistrations, pEventRegistrations, phPeerEvent)#uselib "P2PGRAPH.dll"
#func global PeerGraphRegisterEvent "PeerGraphRegisterEvent" sptr, sptr, sptr, sptr, sptr
; PeerGraphRegisterEvent hGraph, hEvent, cEventRegistrations, varptr(pEventRegistrations), phPeerEvent ; 戻り値は stat
; hGraph : void* -> "sptr"
; hEvent : HANDLE -> "sptr"
; cEventRegistrations : DWORD -> "sptr"
; pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION* -> "sptr"
; phPeerEvent : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "P2PGRAPH.dll" #cfunc global PeerGraphRegisterEvent "PeerGraphRegisterEvent" sptr, sptr, int, var, sptr ; res = PeerGraphRegisterEvent(hGraph, hEvent, cEventRegistrations, pEventRegistrations, phPeerEvent) ; hGraph : void* -> "sptr" ; hEvent : HANDLE -> "sptr" ; cEventRegistrations : DWORD -> "int" ; pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION* -> "var" ; phPeerEvent : void** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "P2PGRAPH.dll" #cfunc global PeerGraphRegisterEvent "PeerGraphRegisterEvent" sptr, sptr, int, sptr, sptr ; res = PeerGraphRegisterEvent(hGraph, hEvent, cEventRegistrations, varptr(pEventRegistrations), phPeerEvent) ; hGraph : void* -> "sptr" ; hEvent : HANDLE -> "sptr" ; cEventRegistrations : DWORD -> "int" ; pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION* -> "sptr" ; phPeerEvent : void** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT PeerGraphRegisterEvent(void* hGraph, HANDLE hEvent, DWORD cEventRegistrations, PEER_GRAPH_EVENT_REGISTRATION* pEventRegistrations, void** phPeerEvent) #uselib "P2PGRAPH.dll" #cfunc global PeerGraphRegisterEvent "PeerGraphRegisterEvent" intptr, intptr, int, var, intptr ; res = PeerGraphRegisterEvent(hGraph, hEvent, cEventRegistrations, pEventRegistrations, phPeerEvent) ; hGraph : void* -> "intptr" ; hEvent : HANDLE -> "intptr" ; cEventRegistrations : DWORD -> "int" ; pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION* -> "var" ; phPeerEvent : void** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT PeerGraphRegisterEvent(void* hGraph, HANDLE hEvent, DWORD cEventRegistrations, PEER_GRAPH_EVENT_REGISTRATION* pEventRegistrations, void** phPeerEvent) #uselib "P2PGRAPH.dll" #cfunc global PeerGraphRegisterEvent "PeerGraphRegisterEvent" intptr, intptr, int, intptr, intptr ; res = PeerGraphRegisterEvent(hGraph, hEvent, cEventRegistrations, varptr(pEventRegistrations), phPeerEvent) ; hGraph : void* -> "intptr" ; hEvent : HANDLE -> "intptr" ; cEventRegistrations : DWORD -> "int" ; pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION* -> "intptr" ; phPeerEvent : void** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
p2pgraph = windows.NewLazySystemDLL("P2PGRAPH.dll")
procPeerGraphRegisterEvent = p2pgraph.NewProc("PeerGraphRegisterEvent")
)
// hGraph (void*), hEvent (HANDLE), cEventRegistrations (DWORD), pEventRegistrations (PEER_GRAPH_EVENT_REGISTRATION*), phPeerEvent (void** out)
r1, _, err := procPeerGraphRegisterEvent.Call(
uintptr(hGraph),
uintptr(hEvent),
uintptr(cEventRegistrations),
uintptr(pEventRegistrations),
uintptr(phPeerEvent),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction PeerGraphRegisterEvent(
hGraph: Pointer; // void*
hEvent: THandle; // HANDLE
cEventRegistrations: DWORD; // DWORD
pEventRegistrations: Pointer; // PEER_GRAPH_EVENT_REGISTRATION*
phPeerEvent: Pointer // void** out
): Integer; stdcall;
external 'P2PGRAPH.dll' name 'PeerGraphRegisterEvent';result := DllCall("P2PGRAPH\PeerGraphRegisterEvent"
, "Ptr", hGraph ; void*
, "Ptr", hEvent ; HANDLE
, "UInt", cEventRegistrations ; DWORD
, "Ptr", pEventRegistrations ; PEER_GRAPH_EVENT_REGISTRATION*
, "Ptr", phPeerEvent ; void** out
, "Int") ; return: HRESULT●PeerGraphRegisterEvent(hGraph, hEvent, cEventRegistrations, pEventRegistrations, phPeerEvent) = DLL("P2PGRAPH.dll", "int PeerGraphRegisterEvent(void*, void*, dword, void*, void*)")
# 呼び出し: PeerGraphRegisterEvent(hGraph, hEvent, cEventRegistrations, pEventRegistrations, phPeerEvent)
# hGraph : void* -> "void*"
# hEvent : HANDLE -> "void*"
# cEventRegistrations : DWORD -> "dword"
# pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION* -> "void*"
# phPeerEvent : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "p2pgraph" fn PeerGraphRegisterEvent(
hGraph: ?*anyopaque, // void*
hEvent: ?*anyopaque, // HANDLE
cEventRegistrations: u32, // DWORD
pEventRegistrations: [*c]PEER_GRAPH_EVENT_REGISTRATION, // PEER_GRAPH_EVENT_REGISTRATION*
phPeerEvent: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;proc PeerGraphRegisterEvent(
hGraph: pointer, # void*
hEvent: pointer, # HANDLE
cEventRegistrations: uint32, # DWORD
pEventRegistrations: ptr PEER_GRAPH_EVENT_REGISTRATION, # PEER_GRAPH_EVENT_REGISTRATION*
phPeerEvent: pointer # void** out
): int32 {.importc: "PeerGraphRegisterEvent", stdcall, dynlib: "P2PGRAPH.dll".}pragma(lib, "p2pgraph");
extern(Windows)
int PeerGraphRegisterEvent(
void* hGraph, // void*
void* hEvent, // HANDLE
uint cEventRegistrations, // DWORD
PEER_GRAPH_EVENT_REGISTRATION* pEventRegistrations, // PEER_GRAPH_EVENT_REGISTRATION*
void** phPeerEvent // void** out
);ccall((:PeerGraphRegisterEvent, "P2PGRAPH.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, UInt32, Ptr{PEER_GRAPH_EVENT_REGISTRATION}, Ptr{Cvoid}),
hGraph, hEvent, cEventRegistrations, pEventRegistrations, phPeerEvent)
# hGraph : void* -> Ptr{Cvoid}
# hEvent : HANDLE -> Ptr{Cvoid}
# cEventRegistrations : DWORD -> UInt32
# pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION* -> Ptr{PEER_GRAPH_EVENT_REGISTRATION}
# phPeerEvent : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t PeerGraphRegisterEvent(
void* hGraph,
void* hEvent,
uint32_t cEventRegistrations,
void* pEventRegistrations,
void** phPeerEvent);
]]
local p2pgraph = ffi.load("p2pgraph")
-- p2pgraph.PeerGraphRegisterEvent(hGraph, hEvent, cEventRegistrations, pEventRegistrations, phPeerEvent)
-- hGraph : void*
-- hEvent : HANDLE
-- cEventRegistrations : DWORD
-- pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION*
-- phPeerEvent : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('P2PGRAPH.dll');
const PeerGraphRegisterEvent = lib.func('__stdcall', 'PeerGraphRegisterEvent', 'int32_t', ['void *', 'void *', 'uint32_t', 'void *', 'void *']);
// PeerGraphRegisterEvent(hGraph, hEvent, cEventRegistrations, pEventRegistrations, phPeerEvent)
// hGraph : void* -> 'void *'
// hEvent : HANDLE -> 'void *'
// cEventRegistrations : DWORD -> 'uint32_t'
// pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION* -> 'void *'
// phPeerEvent : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("P2PGRAPH.dll", {
PeerGraphRegisterEvent: { parameters: ["pointer", "pointer", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.PeerGraphRegisterEvent(hGraph, hEvent, cEventRegistrations, pEventRegistrations, phPeerEvent)
// hGraph : void* -> "pointer"
// hEvent : HANDLE -> "pointer"
// cEventRegistrations : DWORD -> "u32"
// pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION* -> "pointer"
// phPeerEvent : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t PeerGraphRegisterEvent(
void* hGraph,
void* hEvent,
uint32_t cEventRegistrations,
void* pEventRegistrations,
void** phPeerEvent);
C, "P2PGRAPH.dll");
// $ffi->PeerGraphRegisterEvent(hGraph, hEvent, cEventRegistrations, pEventRegistrations, phPeerEvent);
// hGraph : void*
// hEvent : HANDLE
// cEventRegistrations : DWORD
// pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION*
// phPeerEvent : 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 P2pgraph extends StdCallLibrary {
P2pgraph INSTANCE = Native.load("p2pgraph", P2pgraph.class);
int PeerGraphRegisterEvent(
Pointer hGraph, // void*
Pointer hEvent, // HANDLE
int cEventRegistrations, // DWORD
Pointer pEventRegistrations, // PEER_GRAPH_EVENT_REGISTRATION*
Pointer phPeerEvent // void** out
);
}@[Link("p2pgraph")]
lib LibP2PGRAPH
fun PeerGraphRegisterEvent = PeerGraphRegisterEvent(
hGraph : Void*, # void*
hEvent : Void*, # HANDLE
cEventRegistrations : UInt32, # DWORD
pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION*, # PEER_GRAPH_EVENT_REGISTRATION*
phPeerEvent : 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 PeerGraphRegisterEventNative = Int32 Function(Pointer<Void>, Pointer<Void>, Uint32, Pointer<Void>, Pointer<Void>);
typedef PeerGraphRegisterEventDart = int Function(Pointer<Void>, Pointer<Void>, int, Pointer<Void>, Pointer<Void>);
final PeerGraphRegisterEvent = DynamicLibrary.open('P2PGRAPH.dll')
.lookupFunction<PeerGraphRegisterEventNative, PeerGraphRegisterEventDart>('PeerGraphRegisterEvent');
// hGraph : void* -> Pointer<Void>
// hEvent : HANDLE -> Pointer<Void>
// cEventRegistrations : DWORD -> Uint32
// pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION* -> Pointer<Void>
// phPeerEvent : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function PeerGraphRegisterEvent(
hGraph: Pointer; // void*
hEvent: THandle; // HANDLE
cEventRegistrations: DWORD; // DWORD
pEventRegistrations: Pointer; // PEER_GRAPH_EVENT_REGISTRATION*
phPeerEvent: Pointer // void** out
): Integer; stdcall;
external 'P2PGRAPH.dll' name 'PeerGraphRegisterEvent';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "PeerGraphRegisterEvent"
c_PeerGraphRegisterEvent :: Ptr () -> Ptr () -> Word32 -> Ptr () -> Ptr () -> IO Int32
-- hGraph : void* -> Ptr ()
-- hEvent : HANDLE -> Ptr ()
-- cEventRegistrations : DWORD -> Word32
-- pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION* -> Ptr ()
-- phPeerEvent : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let peergraphregisterevent =
foreign "PeerGraphRegisterEvent"
((ptr void) @-> (ptr void) @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* hGraph : void* -> (ptr void) *)
(* hEvent : HANDLE -> (ptr void) *)
(* cEventRegistrations : DWORD -> uint32_t *)
(* pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION* -> (ptr void) *)
(* phPeerEvent : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library p2pgraph (t "P2PGRAPH.dll"))
(cffi:use-foreign-library p2pgraph)
(cffi:defcfun ("PeerGraphRegisterEvent" peer-graph-register-event :convention :stdcall) :int32
(h-graph :pointer) ; void*
(h-event :pointer) ; HANDLE
(c-event-registrations :uint32) ; DWORD
(p-event-registrations :pointer) ; PEER_GRAPH_EVENT_REGISTRATION*
(ph-peer-event :pointer)) ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $PeerGraphRegisterEvent = Win32::API::More->new('P2PGRAPH',
'int PeerGraphRegisterEvent(LPVOID hGraph, HANDLE hEvent, DWORD cEventRegistrations, LPVOID pEventRegistrations, LPVOID phPeerEvent)');
# my $ret = $PeerGraphRegisterEvent->Call($hGraph, $hEvent, $cEventRegistrations, $pEventRegistrations, $phPeerEvent);
# hGraph : void* -> LPVOID
# hEvent : HANDLE -> HANDLE
# cEventRegistrations : DWORD -> DWORD
# pEventRegistrations : PEER_GRAPH_EVENT_REGISTRATION* -> LPVOID
# phPeerEvent : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。