Win32 API 日本語リファレンス
ホームUI.Shell.PropertiesSystem › PSGetImageReferenceForValue

PSGetImageReferenceForValue

関数
プロパティ値に対応する画像参照を取得する。
DLLPROPSYS.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

HRESULT PSGetImageReferenceForValue(
    const PROPERTYKEY* propkey,
    const PROPVARIANT* propvar,
    LPWSTR* ppszImageRes
);

パラメーター

名前方向
propkeyPROPERTYKEY*in
propvarPROPVARIANT*in
ppszImageResLPWSTR*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT PSGetImageReferenceForValue(
    const PROPERTYKEY* propkey,
    const PROPVARIANT* propvar,
    LPWSTR* ppszImageRes
);
[DllImport("PROPSYS.dll", ExactSpelling = true)]
static extern int PSGetImageReferenceForValue(
    IntPtr propkey,   // PROPERTYKEY*
    IntPtr propvar,   // PROPVARIANT*
    IntPtr ppszImageRes   // LPWSTR* out
);
<DllImport("PROPSYS.dll", ExactSpelling:=True)>
Public Shared Function PSGetImageReferenceForValue(
    propkey As IntPtr,   ' PROPERTYKEY*
    propvar As IntPtr,   ' PROPVARIANT*
    ppszImageRes As IntPtr   ' LPWSTR* out
) As Integer
End Function
' propkey : PROPERTYKEY*
' propvar : PROPVARIANT*
' ppszImageRes : LPWSTR* out
Declare PtrSafe Function PSGetImageReferenceForValue Lib "propsys" ( _
    ByVal propkey As LongPtr, _
    ByVal propvar As LongPtr, _
    ByVal ppszImageRes As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PSGetImageReferenceForValue = ctypes.windll.propsys.PSGetImageReferenceForValue
PSGetImageReferenceForValue.restype = ctypes.c_int
PSGetImageReferenceForValue.argtypes = [
    ctypes.c_void_p,  # propkey : PROPERTYKEY*
    ctypes.c_void_p,  # propvar : PROPVARIANT*
    ctypes.c_void_p,  # ppszImageRes : LPWSTR* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	propsys = windows.NewLazySystemDLL("PROPSYS.dll")
	procPSGetImageReferenceForValue = propsys.NewProc("PSGetImageReferenceForValue")
)

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