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

CoGetCallerTID

関数
呼び出し元のスレッドIDを取得する。
DLLOLE32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRESULT CoGetCallerTID(
    DWORD* lpdwTID
);

パラメーター

名前方向
lpdwTIDDWORD*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT CoGetCallerTID(
    DWORD* lpdwTID
);
[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int CoGetCallerTID(
    out uint lpdwTID   // DWORD* out
);
<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function CoGetCallerTID(
    <Out> ByRef lpdwTID As UInteger   ' DWORD* out
) As Integer
End Function
' lpdwTID : DWORD* out
Declare PtrSafe Function CoGetCallerTID Lib "ole32" ( _
    ByRef lpdwTID As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CoGetCallerTID = ctypes.windll.ole32.CoGetCallerTID
CoGetCallerTID.restype = ctypes.c_int
CoGetCallerTID.argtypes = [
    ctypes.POINTER(wintypes.DWORD),  # lpdwTID : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	ole32 = windows.NewLazySystemDLL("OLE32.dll")
	procCoGetCallerTID = ole32.NewProc("CoGetCallerTID")
)

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