Win32 API 日本語リファレンス
ホームSystem.Com › CoDecrementMTAUsage

CoDecrementMTAUsage

関数
CoIncrementMTAUsageで取得したMTA使用参照を解放する。
DLLOLE32.dll呼出規約winapi

シグネチャ

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

HRESULT CoDecrementMTAUsage(
    CO_MTA_USAGE_COOKIE Cookie
);

パラメーター

名前方向
CookieCO_MTA_USAGE_COOKIEin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT CoDecrementMTAUsage(
    CO_MTA_USAGE_COOKIE Cookie
);
[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int CoDecrementMTAUsage(
    IntPtr Cookie   // CO_MTA_USAGE_COOKIE
);
<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function CoDecrementMTAUsage(
    Cookie As IntPtr   ' CO_MTA_USAGE_COOKIE
) As Integer
End Function
' Cookie : CO_MTA_USAGE_COOKIE
Declare PtrSafe Function CoDecrementMTAUsage Lib "ole32" ( _
    ByVal Cookie As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CoDecrementMTAUsage = ctypes.windll.ole32.CoDecrementMTAUsage
CoDecrementMTAUsage.restype = ctypes.c_int
CoDecrementMTAUsage.argtypes = [
    wintypes.HANDLE,  # Cookie : CO_MTA_USAGE_COOKIE
]
require 'fiddle'
require 'fiddle/import'

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

var (
	ole32 = windows.NewLazySystemDLL("OLE32.dll")
	procCoDecrementMTAUsage = ole32.NewProc("CoDecrementMTAUsage")
)

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