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

RtmGetChangedDests

関数
前回の取得以降に変更された宛先の一覧を取得する。
DLLrtm.dll呼出規約winapi対応OSwindowsserver2000

シグネチャ

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

DWORD RtmGetChangedDests(
    INT_PTR RtmRegHandle,
    INT_PTR NotifyHandle,
    DWORD* NumDests,
    RTM_DEST_INFO* ChangedDests
);

パラメーター

名前方向説明
RtmRegHandleINT_PTRinRTMクライアント登録ハンドル。操作対象のルーティングテーブルを識別する。
NotifyHandleINT_PTRinRtmRegisterForChangeNotificationで得た変更通知ハンドル。
NumDestsDWORD*inout入力で配列の容量、出力で実際に書き込まれた変更宛先数を受け渡すDWORDポインタ。
ChangedDestsRTM_DEST_INFO*inout変更された宛先情報(RTM_DEST_INFO)を受け取る呼び出し側確保の配列。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD RtmGetChangedDests(
    INT_PTR RtmRegHandle,
    INT_PTR NotifyHandle,
    DWORD* NumDests,
    RTM_DEST_INFO* ChangedDests
);
[DllImport("rtm.dll", ExactSpelling = true)]
static extern uint RtmGetChangedDests(
    IntPtr RtmRegHandle,   // INT_PTR
    IntPtr NotifyHandle,   // INT_PTR
    ref uint NumDests,   // DWORD* in/out
    IntPtr ChangedDests   // RTM_DEST_INFO* in/out
);
<DllImport("rtm.dll", ExactSpelling:=True)>
Public Shared Function RtmGetChangedDests(
    RtmRegHandle As IntPtr,   ' INT_PTR
    NotifyHandle As IntPtr,   ' INT_PTR
    ByRef NumDests As UInteger,   ' DWORD* in/out
    ChangedDests As IntPtr   ' RTM_DEST_INFO* in/out
) As UInteger
End Function
' RtmRegHandle : INT_PTR
' NotifyHandle : INT_PTR
' NumDests : DWORD* in/out
' ChangedDests : RTM_DEST_INFO* in/out
Declare PtrSafe Function RtmGetChangedDests Lib "rtm" ( _
    ByVal RtmRegHandle As LongPtr, _
    ByVal NotifyHandle As LongPtr, _
    ByRef NumDests As Long, _
    ByVal ChangedDests As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RtmGetChangedDests = ctypes.windll.rtm.RtmGetChangedDests
RtmGetChangedDests.restype = wintypes.DWORD
RtmGetChangedDests.argtypes = [
    ctypes.c_ssize_t,  # RtmRegHandle : INT_PTR
    ctypes.c_ssize_t,  # NotifyHandle : INT_PTR
    ctypes.POINTER(wintypes.DWORD),  # NumDests : DWORD* in/out
    ctypes.c_void_p,  # ChangedDests : RTM_DEST_INFO* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rtm = windows.NewLazySystemDLL("rtm.dll")
	procRtmGetChangedDests = rtm.NewProc("RtmGetChangedDests")
)

// RtmRegHandle (INT_PTR), NotifyHandle (INT_PTR), NumDests (DWORD* in/out), ChangedDests (RTM_DEST_INFO* in/out)
r1, _, err := procRtmGetChangedDests.Call(
	uintptr(RtmRegHandle),
	uintptr(NotifyHandle),
	uintptr(NumDests),
	uintptr(ChangedDests),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function RtmGetChangedDests(
  RtmRegHandle: NativeInt;   // INT_PTR
  NotifyHandle: NativeInt;   // INT_PTR
  NumDests: Pointer;   // DWORD* in/out
  ChangedDests: Pointer   // RTM_DEST_INFO* in/out
): DWORD; stdcall;
  external 'rtm.dll' name 'RtmGetChangedDests';
result := DllCall("rtm\RtmGetChangedDests"
    , "Ptr", RtmRegHandle   ; INT_PTR
    , "Ptr", NotifyHandle   ; INT_PTR
    , "Ptr", NumDests   ; DWORD* in/out
    , "Ptr", ChangedDests   ; RTM_DEST_INFO* in/out
    , "UInt")   ; return: DWORD
●RtmGetChangedDests(RtmRegHandle, NotifyHandle, NumDests, ChangedDests) = DLL("rtm.dll", "dword RtmGetChangedDests(int, int, void*, void*)")
# 呼び出し: RtmGetChangedDests(RtmRegHandle, NotifyHandle, NumDests, ChangedDests)
# RtmRegHandle : INT_PTR -> "int"
# NotifyHandle : INT_PTR -> "int"
# NumDests : DWORD* in/out -> "void*"
# ChangedDests : RTM_DEST_INFO* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

foreign import stdcall safe "RtmGetChangedDests"
  c_RtmGetChangedDests :: CIntPtr -> CIntPtr -> Ptr Word32 -> Ptr () -> IO Word32
-- RtmRegHandle : INT_PTR -> CIntPtr
-- NotifyHandle : INT_PTR -> CIntPtr
-- NumDests : DWORD* in/out -> Ptr Word32
-- ChangedDests : RTM_DEST_INFO* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let rtmgetchangeddests =
  foreign "RtmGetChangedDests"
    (intptr_t @-> intptr_t @-> (ptr uint32_t) @-> (ptr void) @-> returning uint32_t)
(* RtmRegHandle : INT_PTR -> intptr_t *)
(* NotifyHandle : INT_PTR -> intptr_t *)
(* NumDests : DWORD* in/out -> (ptr uint32_t) *)
(* ChangedDests : RTM_DEST_INFO* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library rtm (t "rtm.dll"))
(cffi:use-foreign-library rtm)

(cffi:defcfun ("RtmGetChangedDests" rtm-get-changed-dests :convention :stdcall) :uint32
  (rtm-reg-handle :int64)   ; INT_PTR
  (notify-handle :int64)   ; INT_PTR
  (num-dests :pointer)   ; DWORD* in/out
  (changed-dests :pointer))   ; RTM_DEST_INFO* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RtmGetChangedDests = Win32::API::More->new('rtm',
    'DWORD RtmGetChangedDests(LPARAM RtmRegHandle, LPARAM NotifyHandle, LPVOID NumDests, LPVOID ChangedDests)');
# my $ret = $RtmGetChangedDests->Call($RtmRegHandle, $NotifyHandle, $NumDests, $ChangedDests);
# RtmRegHandle : INT_PTR -> LPARAM
# NotifyHandle : INT_PTR -> LPARAM
# NumDests : DWORD* in/out -> LPVOID
# ChangedDests : RTM_DEST_INFO* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型