ホーム › System.Com › CoLockObjectExternal
CoLockObjectExternal
関数オブジェクトを外部参照でロックまたはロック解除する。
シグネチャ
// OLE32.dll
#include <windows.h>
HRESULT CoLockObjectExternal(
IUnknown* pUnk,
BOOL fLock,
BOOL fLastUnlockReleases
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pUnk | IUnknown* | in |
| fLock | BOOL | in |
| fLastUnlockReleases | BOOL | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// OLE32.dll
#include <windows.h>
HRESULT CoLockObjectExternal(
IUnknown* pUnk,
BOOL fLock,
BOOL fLastUnlockReleases
);[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int CoLockObjectExternal(
IntPtr pUnk, // IUnknown*
bool fLock, // BOOL
bool fLastUnlockReleases // BOOL
);<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function CoLockObjectExternal(
pUnk As IntPtr, ' IUnknown*
fLock As Boolean, ' BOOL
fLastUnlockReleases As Boolean ' BOOL
) As Integer
End Function' pUnk : IUnknown*
' fLock : BOOL
' fLastUnlockReleases : BOOL
Declare PtrSafe Function CoLockObjectExternal Lib "ole32" ( _
ByVal pUnk As LongPtr, _
ByVal fLock As Long, _
ByVal fLastUnlockReleases As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CoLockObjectExternal = ctypes.windll.ole32.CoLockObjectExternal
CoLockObjectExternal.restype = ctypes.c_int
CoLockObjectExternal.argtypes = [
ctypes.c_void_p, # pUnk : IUnknown*
wintypes.BOOL, # fLock : BOOL
wintypes.BOOL, # fLastUnlockReleases : BOOL
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLE32.dll')
CoLockObjectExternal = Fiddle::Function.new(
lib['CoLockObjectExternal'],
[
Fiddle::TYPE_VOIDP, # pUnk : IUnknown*
Fiddle::TYPE_INT, # fLock : BOOL
Fiddle::TYPE_INT, # fLastUnlockReleases : BOOL
],
Fiddle::TYPE_INT)#[link(name = "ole32")]
extern "system" {
fn CoLockObjectExternal(
pUnk: *mut core::ffi::c_void, // IUnknown*
fLock: i32, // BOOL
fLastUnlockReleases: i32 // BOOL
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLE32.dll")]
public static extern int CoLockObjectExternal(IntPtr pUnk, bool fLock, bool fLastUnlockReleases);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLE32_CoLockObjectExternal' -Namespace Win32 -PassThru
# $api::CoLockObjectExternal(pUnk, fLock, fLastUnlockReleases)#uselib "OLE32.dll"
#func global CoLockObjectExternal "CoLockObjectExternal" sptr, sptr, sptr
; CoLockObjectExternal pUnk, fLock, fLastUnlockReleases ; 戻り値は stat
; pUnk : IUnknown* -> "sptr"
; fLock : BOOL -> "sptr"
; fLastUnlockReleases : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "OLE32.dll"
#cfunc global CoLockObjectExternal "CoLockObjectExternal" sptr, int, int
; res = CoLockObjectExternal(pUnk, fLock, fLastUnlockReleases)
; pUnk : IUnknown* -> "sptr"
; fLock : BOOL -> "int"
; fLastUnlockReleases : BOOL -> "int"; HRESULT CoLockObjectExternal(IUnknown* pUnk, BOOL fLock, BOOL fLastUnlockReleases)
#uselib "OLE32.dll"
#cfunc global CoLockObjectExternal "CoLockObjectExternal" intptr, int, int
; res = CoLockObjectExternal(pUnk, fLock, fLastUnlockReleases)
; pUnk : IUnknown* -> "intptr"
; fLock : BOOL -> "int"
; fLastUnlockReleases : BOOL -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ole32 = windows.NewLazySystemDLL("OLE32.dll")
procCoLockObjectExternal = ole32.NewProc("CoLockObjectExternal")
)
// pUnk (IUnknown*), fLock (BOOL), fLastUnlockReleases (BOOL)
r1, _, err := procCoLockObjectExternal.Call(
uintptr(pUnk),
uintptr(fLock),
uintptr(fLastUnlockReleases),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction CoLockObjectExternal(
pUnk: Pointer; // IUnknown*
fLock: BOOL; // BOOL
fLastUnlockReleases: BOOL // BOOL
): Integer; stdcall;
external 'OLE32.dll' name 'CoLockObjectExternal';result := DllCall("OLE32\CoLockObjectExternal"
, "Ptr", pUnk ; IUnknown*
, "Int", fLock ; BOOL
, "Int", fLastUnlockReleases ; BOOL
, "Int") ; return: HRESULT●CoLockObjectExternal(pUnk, fLock, fLastUnlockReleases) = DLL("OLE32.dll", "int CoLockObjectExternal(void*, bool, bool)")
# 呼び出し: CoLockObjectExternal(pUnk, fLock, fLastUnlockReleases)
# pUnk : IUnknown* -> "void*"
# fLock : BOOL -> "bool"
# fLastUnlockReleases : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。