ホーム › System.Com › CoInvalidateRemoteMachineBindings
CoInvalidateRemoteMachineBindings
関数指定マシンへのリモートバインディングを無効化する。
シグネチャ
// OLE32.dll
#include <windows.h>
HRESULT CoInvalidateRemoteMachineBindings(
LPWSTR pszMachineName
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pszMachineName | LPWSTR | in | バインディング ハンドルをフラッシュする対象のコンピューター名。空の文字列を指定すると、キャッシュ内のすべてのハンドルをフラッシュします。 |
戻り値の型: HRESULT
公式ドキュメント
指定したコンピューターに対してキャッシュされている RPC バインディング ハンドルをフラッシュするよう、サービス コントロール マネージャーに指示します。
戻り値
この関数は次の値を返すことがあります。
| 戻り値 | 説明 |
|---|---|
| 成功を示します。 | |
| 指定したコンピューター名が見つからなかったか、バインディング ハンドルのキャッシュが空であったことを示します。後者は、特定のコンピューター名ではなく空の文字列が渡されたことを意味します。 | |
| 呼び出し元がこのコンピューターの管理者ではなかったことを示します。 | |
| pszMachineName に NULL 値が渡されたことを示します。 |
解説(Remarks)
OLE Service Control Manager は、COM がコンポーネントのアクティブ化要求を他のマシンに送信するために使用されます。これを行うため、OLE Service Control Manager は、コンピューターへアクティブ化要求を送信するための RPC バインディング ハンドルのキャッシュを、コンピューター名をキーとして保持しています。通常はこれで問題ありませんが、Web ファームや負荷分散などのシナリオでは、同じ名前の別の物理サーバーへ再バインドできるようにするために、特定のハンドルをこのキャッシュから消去する機能が必要になる場合があります。CoInvalidateRemoteMachineBindings はこの目的のために使用されます。
OLE Service Control Manager は、使用されていないバインディング ハンドルを時間の経過とともにフラッシュします。これを行うために CoInvalidateRemoteMachineBindings を呼び出す必要はありません。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// OLE32.dll
#include <windows.h>
HRESULT CoInvalidateRemoteMachineBindings(
LPWSTR pszMachineName
);[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int CoInvalidateRemoteMachineBindings(
[MarshalAs(UnmanagedType.LPWStr)] string pszMachineName // LPWSTR
);<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function CoInvalidateRemoteMachineBindings(
<MarshalAs(UnmanagedType.LPWStr)> pszMachineName As String ' LPWSTR
) As Integer
End Function' pszMachineName : LPWSTR
Declare PtrSafe Function CoInvalidateRemoteMachineBindings Lib "ole32" ( _
ByVal pszMachineName As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CoInvalidateRemoteMachineBindings = ctypes.windll.ole32.CoInvalidateRemoteMachineBindings
CoInvalidateRemoteMachineBindings.restype = ctypes.c_int
CoInvalidateRemoteMachineBindings.argtypes = [
wintypes.LPCWSTR, # pszMachineName : LPWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLE32.dll')
CoInvalidateRemoteMachineBindings = Fiddle::Function.new(
lib['CoInvalidateRemoteMachineBindings'],
[
Fiddle::TYPE_VOIDP, # pszMachineName : LPWSTR
],
Fiddle::TYPE_INT)#[link(name = "ole32")]
extern "system" {
fn CoInvalidateRemoteMachineBindings(
pszMachineName: *mut u16 // LPWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLE32.dll")]
public static extern int CoInvalidateRemoteMachineBindings([MarshalAs(UnmanagedType.LPWStr)] string pszMachineName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLE32_CoInvalidateRemoteMachineBindings' -Namespace Win32 -PassThru
# $api::CoInvalidateRemoteMachineBindings(pszMachineName)#uselib "OLE32.dll"
#func global CoInvalidateRemoteMachineBindings "CoInvalidateRemoteMachineBindings" sptr
; CoInvalidateRemoteMachineBindings pszMachineName ; 戻り値は stat
; pszMachineName : LPWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "OLE32.dll"
#cfunc global CoInvalidateRemoteMachineBindings "CoInvalidateRemoteMachineBindings" wstr
; res = CoInvalidateRemoteMachineBindings(pszMachineName)
; pszMachineName : LPWSTR -> "wstr"; HRESULT CoInvalidateRemoteMachineBindings(LPWSTR pszMachineName)
#uselib "OLE32.dll"
#cfunc global CoInvalidateRemoteMachineBindings "CoInvalidateRemoteMachineBindings" wstr
; res = CoInvalidateRemoteMachineBindings(pszMachineName)
; pszMachineName : LPWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ole32 = windows.NewLazySystemDLL("OLE32.dll")
procCoInvalidateRemoteMachineBindings = ole32.NewProc("CoInvalidateRemoteMachineBindings")
)
// pszMachineName (LPWSTR)
r1, _, err := procCoInvalidateRemoteMachineBindings.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszMachineName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction CoInvalidateRemoteMachineBindings(
pszMachineName: PWideChar // LPWSTR
): Integer; stdcall;
external 'OLE32.dll' name 'CoInvalidateRemoteMachineBindings';result := DllCall("OLE32\CoInvalidateRemoteMachineBindings"
, "WStr", pszMachineName ; LPWSTR
, "Int") ; return: HRESULT●CoInvalidateRemoteMachineBindings(pszMachineName) = DLL("OLE32.dll", "int CoInvalidateRemoteMachineBindings(char*)")
# 呼び出し: CoInvalidateRemoteMachineBindings(pszMachineName)
# pszMachineName : LPWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "ole32" fn CoInvalidateRemoteMachineBindings(
pszMachineName: [*c]const u16 // LPWSTR
) callconv(std.os.windows.WINAPI) i32;proc CoInvalidateRemoteMachineBindings(
pszMachineName: WideCString # LPWSTR
): int32 {.importc: "CoInvalidateRemoteMachineBindings", stdcall, dynlib: "OLE32.dll".}pragma(lib, "ole32");
extern(Windows)
int CoInvalidateRemoteMachineBindings(
const(wchar)* pszMachineName // LPWSTR
);ccall((:CoInvalidateRemoteMachineBindings, "OLE32.dll"), stdcall, Int32,
(Cwstring,),
pszMachineName)
# pszMachineName : LPWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t CoInvalidateRemoteMachineBindings(
const uint16_t* pszMachineName);
]]
local ole32 = ffi.load("ole32")
-- ole32.CoInvalidateRemoteMachineBindings(pszMachineName)
-- pszMachineName : LPWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('OLE32.dll');
const CoInvalidateRemoteMachineBindings = lib.func('__stdcall', 'CoInvalidateRemoteMachineBindings', 'int32_t', ['str16']);
// CoInvalidateRemoteMachineBindings(pszMachineName)
// pszMachineName : LPWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("OLE32.dll", {
CoInvalidateRemoteMachineBindings: { parameters: ["buffer"], result: "i32" },
});
// lib.symbols.CoInvalidateRemoteMachineBindings(pszMachineName)
// pszMachineName : LPWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CoInvalidateRemoteMachineBindings(
const uint16_t* pszMachineName);
C, "OLE32.dll");
// $ffi->CoInvalidateRemoteMachineBindings(pszMachineName);
// pszMachineName : LPWSTR
// 構造体/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 CoInvalidateRemoteMachineBindings(
WString pszMachineName // LPWSTR
);
}@[Link("ole32")]
lib LibOLE32
fun CoInvalidateRemoteMachineBindings = CoInvalidateRemoteMachineBindings(
pszMachineName : UInt16* # LPWSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CoInvalidateRemoteMachineBindingsNative = Int32 Function(Pointer<Utf16>);
typedef CoInvalidateRemoteMachineBindingsDart = int Function(Pointer<Utf16>);
final CoInvalidateRemoteMachineBindings = DynamicLibrary.open('OLE32.dll')
.lookupFunction<CoInvalidateRemoteMachineBindingsNative, CoInvalidateRemoteMachineBindingsDart>('CoInvalidateRemoteMachineBindings');
// pszMachineName : LPWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CoInvalidateRemoteMachineBindings(
pszMachineName: PWideChar // LPWSTR
): Integer; stdcall;
external 'OLE32.dll' name 'CoInvalidateRemoteMachineBindings';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CoInvalidateRemoteMachineBindings"
c_CoInvalidateRemoteMachineBindings :: CWString -> IO Int32
-- pszMachineName : LPWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let coinvalidateremotemachinebindings =
foreign "CoInvalidateRemoteMachineBindings"
((ptr uint16_t) @-> returning int32_t)
(* pszMachineName : LPWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ole32 (t "OLE32.dll"))
(cffi:use-foreign-library ole32)
(cffi:defcfun ("CoInvalidateRemoteMachineBindings" co-invalidate-remote-machine-bindings :convention :stdcall) :int32
(psz-machine-name (:string :encoding :utf-16le))) ; LPWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CoInvalidateRemoteMachineBindings = Win32::API::More->new('OLE32',
'int CoInvalidateRemoteMachineBindings(LPCWSTR pszMachineName)');
# my $ret = $CoInvalidateRemoteMachineBindings->Call($pszMachineName);
# pszMachineName : LPWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。