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