GetRunningObjectTable
関数シグネチャ
// OLE32.dll
#include <windows.h>
HRESULT GetRunningObjectTable(
DWORD reserved,
IRunningObjectTable** pprot
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| reserved | DWORD | in | このパラメーターは予約されており、0 を指定する必要があります。 |
| pprot | IRunningObjectTable** | out | ローカル ROT へのインターフェイス ポインターを受け取る IRunningObjectTable* ポインター変数のアドレスです。関数が成功した場合、呼び出し側はそのインターフェイス ポインターに対して Release を呼び出す責任があります。エラーが発生した場合、*pprot は未定義です。 |
戻り値の型: HRESULT
公式ドキュメント
ローカルの実行中オブジェクト テーブル (ROT) 上の IRunningObjectTable インターフェイスへのポインターを返します。
戻り値
この関数は、標準的な戻り値 E_UNEXPECTED および S_OK を返すことがあります。
解説(Remarks)
各ワークステーションには、そのコンピューター上で実行中として登録されているオブジェクトのテーブルを保持するローカル ROT があります。この関数は、そのテーブルへのアクセスを提供する IRunningObjectTable インターフェイス ポインターを返します。
オブジェクトを識別するモニカーを配布して他者からアクセスできるようにするモニカー プロバイダーは、GetRunningObjectTable を呼び出す必要があります。この関数が返すインターフェイス ポインターを使用して、オブジェクトの実行開始時にそれらを登録し、それらのオブジェクトが変更された時刻を記録し、実行を停止したときに登録を取り消します。詳細については、IRunningObjectTable インターフェイスを参照してください。
複合ドキュメントのリンク ソースは、モニカー プロバイダーの最も一般的な例です。これには、ドキュメント (またはドキュメントの一部) へのリンクをサポートするサーバー アプリケーションや、ドキュメント内の埋め込みオブジェクトへのリンクをサポートするコンテナー アプリケーションが含まれます。リンクをサポートしないサーバー アプリケーションでも、ROT を使用して、埋め込みオブジェクトへのリンクをサポートするコンテナー アプリケーションと連携できます。
新しいモニカー クラスを記述するために IMoniker インターフェイスを実装しており、ROT へのインターフェイス ポインターが必要な場合は、GetRunningObjectTable 関数ではなく IBindCtx::GetRunningObjectTable を呼び出してください。これにより、将来の IBindCtx インターフェイスの実装でバインド動作を変更できるようになります。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// OLE32.dll
#include <windows.h>
HRESULT GetRunningObjectTable(
DWORD reserved,
IRunningObjectTable** pprot
);[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int GetRunningObjectTable(
uint reserved, // DWORD
IntPtr pprot // IRunningObjectTable** out
);<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function GetRunningObjectTable(
reserved As UInteger, ' DWORD
pprot As IntPtr ' IRunningObjectTable** out
) As Integer
End Function' reserved : DWORD
' pprot : IRunningObjectTable** out
Declare PtrSafe Function GetRunningObjectTable Lib "ole32" ( _
ByVal reserved As Long, _
ByVal pprot As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetRunningObjectTable = ctypes.windll.ole32.GetRunningObjectTable
GetRunningObjectTable.restype = ctypes.c_int
GetRunningObjectTable.argtypes = [
wintypes.DWORD, # reserved : DWORD
ctypes.c_void_p, # pprot : IRunningObjectTable** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLE32.dll')
GetRunningObjectTable = Fiddle::Function.new(
lib['GetRunningObjectTable'],
[
-Fiddle::TYPE_INT, # reserved : DWORD
Fiddle::TYPE_VOIDP, # pprot : IRunningObjectTable** out
],
Fiddle::TYPE_INT)#[link(name = "ole32")]
extern "system" {
fn GetRunningObjectTable(
reserved: u32, // DWORD
pprot: *mut *mut core::ffi::c_void // IRunningObjectTable** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLE32.dll")]
public static extern int GetRunningObjectTable(uint reserved, IntPtr pprot);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLE32_GetRunningObjectTable' -Namespace Win32 -PassThru
# $api::GetRunningObjectTable(reserved, pprot)#uselib "OLE32.dll"
#func global GetRunningObjectTable "GetRunningObjectTable" sptr, sptr
; GetRunningObjectTable reserved, pprot ; 戻り値は stat
; reserved : DWORD -> "sptr"
; pprot : IRunningObjectTable** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "OLE32.dll"
#cfunc global GetRunningObjectTable "GetRunningObjectTable" int, sptr
; res = GetRunningObjectTable(reserved, pprot)
; reserved : DWORD -> "int"
; pprot : IRunningObjectTable** out -> "sptr"; HRESULT GetRunningObjectTable(DWORD reserved, IRunningObjectTable** pprot)
#uselib "OLE32.dll"
#cfunc global GetRunningObjectTable "GetRunningObjectTable" int, intptr
; res = GetRunningObjectTable(reserved, pprot)
; reserved : DWORD -> "int"
; pprot : IRunningObjectTable** out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ole32 = windows.NewLazySystemDLL("OLE32.dll")
procGetRunningObjectTable = ole32.NewProc("GetRunningObjectTable")
)
// reserved (DWORD), pprot (IRunningObjectTable** out)
r1, _, err := procGetRunningObjectTable.Call(
uintptr(reserved),
uintptr(pprot),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction GetRunningObjectTable(
reserved: DWORD; // DWORD
pprot: Pointer // IRunningObjectTable** out
): Integer; stdcall;
external 'OLE32.dll' name 'GetRunningObjectTable';result := DllCall("OLE32\GetRunningObjectTable"
, "UInt", reserved ; DWORD
, "Ptr", pprot ; IRunningObjectTable** out
, "Int") ; return: HRESULT●GetRunningObjectTable(reserved, pprot) = DLL("OLE32.dll", "int GetRunningObjectTable(dword, void*)")
# 呼び出し: GetRunningObjectTable(reserved, pprot)
# reserved : DWORD -> "dword"
# pprot : IRunningObjectTable** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "ole32" fn GetRunningObjectTable(
reserved: u32, // DWORD
pprot: ?*anyopaque // IRunningObjectTable** out
) callconv(std.os.windows.WINAPI) i32;proc GetRunningObjectTable(
reserved: uint32, # DWORD
pprot: pointer # IRunningObjectTable** out
): int32 {.importc: "GetRunningObjectTable", stdcall, dynlib: "OLE32.dll".}pragma(lib, "ole32");
extern(Windows)
int GetRunningObjectTable(
uint reserved, // DWORD
void* pprot // IRunningObjectTable** out
);ccall((:GetRunningObjectTable, "OLE32.dll"), stdcall, Int32,
(UInt32, Ptr{Cvoid}),
reserved, pprot)
# reserved : DWORD -> UInt32
# pprot : IRunningObjectTable** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GetRunningObjectTable(
uint32_t reserved,
void* pprot);
]]
local ole32 = ffi.load("ole32")
-- ole32.GetRunningObjectTable(reserved, pprot)
-- reserved : DWORD
-- pprot : IRunningObjectTable** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('OLE32.dll');
const GetRunningObjectTable = lib.func('__stdcall', 'GetRunningObjectTable', 'int32_t', ['uint32_t', 'void *']);
// GetRunningObjectTable(reserved, pprot)
// reserved : DWORD -> 'uint32_t'
// pprot : IRunningObjectTable** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("OLE32.dll", {
GetRunningObjectTable: { parameters: ["u32", "pointer"], result: "i32" },
});
// lib.symbols.GetRunningObjectTable(reserved, pprot)
// reserved : DWORD -> "u32"
// pprot : IRunningObjectTable** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GetRunningObjectTable(
uint32_t reserved,
void* pprot);
C, "OLE32.dll");
// $ffi->GetRunningObjectTable(reserved, pprot);
// reserved : DWORD
// pprot : IRunningObjectTable** 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 Ole32 extends StdCallLibrary {
Ole32 INSTANCE = Native.load("ole32", Ole32.class);
int GetRunningObjectTable(
int reserved, // DWORD
Pointer pprot // IRunningObjectTable** out
);
}@[Link("ole32")]
lib LibOLE32
fun GetRunningObjectTable = GetRunningObjectTable(
reserved : UInt32, # DWORD
pprot : Void* # IRunningObjectTable** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetRunningObjectTableNative = Int32 Function(Uint32, Pointer<Void>);
typedef GetRunningObjectTableDart = int Function(int, Pointer<Void>);
final GetRunningObjectTable = DynamicLibrary.open('OLE32.dll')
.lookupFunction<GetRunningObjectTableNative, GetRunningObjectTableDart>('GetRunningObjectTable');
// reserved : DWORD -> Uint32
// pprot : IRunningObjectTable** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetRunningObjectTable(
reserved: DWORD; // DWORD
pprot: Pointer // IRunningObjectTable** out
): Integer; stdcall;
external 'OLE32.dll' name 'GetRunningObjectTable';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetRunningObjectTable"
c_GetRunningObjectTable :: Word32 -> Ptr () -> IO Int32
-- reserved : DWORD -> Word32
-- pprot : IRunningObjectTable** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getrunningobjecttable =
foreign "GetRunningObjectTable"
(uint32_t @-> (ptr void) @-> returning int32_t)
(* reserved : DWORD -> uint32_t *)
(* pprot : IRunningObjectTable** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ole32 (t "OLE32.dll"))
(cffi:use-foreign-library ole32)
(cffi:defcfun ("GetRunningObjectTable" get-running-object-table :convention :stdcall) :int32
(reserved :uint32) ; DWORD
(pprot :pointer)) ; IRunningObjectTable** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetRunningObjectTable = Win32::API::More->new('OLE32',
'int GetRunningObjectTable(DWORD reserved, LPVOID pprot)');
# my $ret = $GetRunningObjectTable->Call($reserved, $pprot);
# reserved : DWORD -> DWORD
# pprot : IRunningObjectTable** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。