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