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

OnDemandRegisterNotification

関数
オンデマンド接続の変更通知コールバックを登録する。
DLLOnDemandConnRouteHelper.dll呼出規約winapi対応OSWindows 8.1 以降

シグネチャ

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

HRESULT OnDemandRegisterNotification(
    ONDEMAND_NOTIFICATION_CALLBACK callback,
    void* callbackContext,   // optional
    HANDLE* registrationHandle
);

パラメーター

名前方向
callbackONDEMAND_NOTIFICATION_CALLBACKin
callbackContextvoid*inoptional
registrationHandleHANDLE*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT OnDemandRegisterNotification(
    ONDEMAND_NOTIFICATION_CALLBACK callback,
    void* callbackContext,   // optional
    HANDLE* registrationHandle
);
[DllImport("OnDemandConnRouteHelper.dll", ExactSpelling = true)]
static extern int OnDemandRegisterNotification(
    IntPtr callback,   // ONDEMAND_NOTIFICATION_CALLBACK
    IntPtr callbackContext,   // void* optional
    IntPtr registrationHandle   // HANDLE* out
);
<DllImport("OnDemandConnRouteHelper.dll", ExactSpelling:=True)>
Public Shared Function OnDemandRegisterNotification(
    callback As IntPtr,   ' ONDEMAND_NOTIFICATION_CALLBACK
    callbackContext As IntPtr,   ' void* optional
    registrationHandle As IntPtr   ' HANDLE* out
) As Integer
End Function
' callback : ONDEMAND_NOTIFICATION_CALLBACK
' callbackContext : void* optional
' registrationHandle : HANDLE* out
Declare PtrSafe Function OnDemandRegisterNotification Lib "ondemandconnroutehelper" ( _
    ByVal callback As LongPtr, _
    ByVal callbackContext As LongPtr, _
    ByVal registrationHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

OnDemandRegisterNotification = ctypes.windll.ondemandconnroutehelper.OnDemandRegisterNotification
OnDemandRegisterNotification.restype = ctypes.c_int
OnDemandRegisterNotification.argtypes = [
    ctypes.c_void_p,  # callback : ONDEMAND_NOTIFICATION_CALLBACK
    ctypes.POINTER(None),  # callbackContext : void* optional
    ctypes.c_void_p,  # registrationHandle : HANDLE* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('OnDemandConnRouteHelper.dll')
OnDemandRegisterNotification = Fiddle::Function.new(
  lib['OnDemandRegisterNotification'],
  [
    Fiddle::TYPE_VOIDP,  # callback : ONDEMAND_NOTIFICATION_CALLBACK
    Fiddle::TYPE_VOIDP,  # callbackContext : void* optional
    Fiddle::TYPE_VOIDP,  # registrationHandle : HANDLE* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "ondemandconnroutehelper")]
extern "system" {
    fn OnDemandRegisterNotification(
        callback: *const core::ffi::c_void,  // ONDEMAND_NOTIFICATION_CALLBACK
        callbackContext: *mut (),  // void* optional
        registrationHandle: *mut *mut core::ffi::c_void  // HANDLE* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("OnDemandConnRouteHelper.dll")]
public static extern int OnDemandRegisterNotification(IntPtr callback, IntPtr callbackContext, IntPtr registrationHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OnDemandConnRouteHelper_OnDemandRegisterNotification' -Namespace Win32 -PassThru
# $api::OnDemandRegisterNotification(callback, callbackContext, registrationHandle)
#uselib "OnDemandConnRouteHelper.dll"
#func global OnDemandRegisterNotification "OnDemandRegisterNotification" sptr, sptr, sptr
; OnDemandRegisterNotification callback, callbackContext, registrationHandle   ; 戻り値は stat
; callback : ONDEMAND_NOTIFICATION_CALLBACK -> "sptr"
; callbackContext : void* optional -> "sptr"
; registrationHandle : HANDLE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "OnDemandConnRouteHelper.dll"
#cfunc global OnDemandRegisterNotification "OnDemandRegisterNotification" sptr, sptr, sptr
; res = OnDemandRegisterNotification(callback, callbackContext, registrationHandle)
; callback : ONDEMAND_NOTIFICATION_CALLBACK -> "sptr"
; callbackContext : void* optional -> "sptr"
; registrationHandle : HANDLE* out -> "sptr"
; HRESULT OnDemandRegisterNotification(ONDEMAND_NOTIFICATION_CALLBACK callback, void* callbackContext, HANDLE* registrationHandle)
#uselib "OnDemandConnRouteHelper.dll"
#cfunc global OnDemandRegisterNotification "OnDemandRegisterNotification" intptr, intptr, intptr
; res = OnDemandRegisterNotification(callback, callbackContext, registrationHandle)
; callback : ONDEMAND_NOTIFICATION_CALLBACK -> "intptr"
; callbackContext : void* optional -> "intptr"
; registrationHandle : HANDLE* out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ondemandconnroutehelper = windows.NewLazySystemDLL("OnDemandConnRouteHelper.dll")
	procOnDemandRegisterNotification = ondemandconnroutehelper.NewProc("OnDemandRegisterNotification")
)

// callback (ONDEMAND_NOTIFICATION_CALLBACK), callbackContext (void* optional), registrationHandle (HANDLE* out)
r1, _, err := procOnDemandRegisterNotification.Call(
	uintptr(callback),
	uintptr(callbackContext),
	uintptr(registrationHandle),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function OnDemandRegisterNotification(
  callback: Pointer;   // ONDEMAND_NOTIFICATION_CALLBACK
  callbackContext: Pointer;   // void* optional
  registrationHandle: Pointer   // HANDLE* out
): Integer; stdcall;
  external 'OnDemandConnRouteHelper.dll' name 'OnDemandRegisterNotification';
result := DllCall("OnDemandConnRouteHelper\OnDemandRegisterNotification"
    , "Ptr", callback   ; ONDEMAND_NOTIFICATION_CALLBACK
    , "Ptr", callbackContext   ; void* optional
    , "Ptr", registrationHandle   ; HANDLE* out
    , "Int")   ; return: HRESULT
●OnDemandRegisterNotification(callback, callbackContext, registrationHandle) = DLL("OnDemandConnRouteHelper.dll", "int OnDemandRegisterNotification(void*, void*, void*)")
# 呼び出し: OnDemandRegisterNotification(callback, callbackContext, registrationHandle)
# callback : ONDEMAND_NOTIFICATION_CALLBACK -> "void*"
# callbackContext : void* optional -> "void*"
# registrationHandle : HANDLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。