ホーム › UI.Shell.PropertiesSystem › PSFormatPropertyValue
PSFormatPropertyValue
関数プロパティストアの値を表示用文字列に整形する。
シグネチャ
// PROPSYS.dll
#include <windows.h>
HRESULT PSFormatPropertyValue(
IPropertyStore* pps,
IPropertyDescription* ppd,
PROPDESC_FORMAT_FLAGS pdff,
LPWSTR* ppszDisplay
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pps | IPropertyStore* | in | 値を取得するプロパティストア。 |
| ppd | IPropertyDescription* | in | 整形対象プロパティの記述子。 |
| pdff | PROPDESC_FORMAT_FLAGS | in | 表示整形の動作を制御するPROPDESC_FORMAT_FLAGS。 |
| ppszDisplay | LPWSTR* | out | 整形した表示文字列を受け取る出力先。CoTaskMemFreeで解放する。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// PROPSYS.dll
#include <windows.h>
HRESULT PSFormatPropertyValue(
IPropertyStore* pps,
IPropertyDescription* ppd,
PROPDESC_FORMAT_FLAGS pdff,
LPWSTR* ppszDisplay
);[DllImport("PROPSYS.dll", ExactSpelling = true)]
static extern int PSFormatPropertyValue(
IntPtr pps, // IPropertyStore*
IntPtr ppd, // IPropertyDescription*
int pdff, // PROPDESC_FORMAT_FLAGS
IntPtr ppszDisplay // LPWSTR* out
);<DllImport("PROPSYS.dll", ExactSpelling:=True)>
Public Shared Function PSFormatPropertyValue(
pps As IntPtr, ' IPropertyStore*
ppd As IntPtr, ' IPropertyDescription*
pdff As Integer, ' PROPDESC_FORMAT_FLAGS
ppszDisplay As IntPtr ' LPWSTR* out
) As Integer
End Function' pps : IPropertyStore*
' ppd : IPropertyDescription*
' pdff : PROPDESC_FORMAT_FLAGS
' ppszDisplay : LPWSTR* out
Declare PtrSafe Function PSFormatPropertyValue Lib "propsys" ( _
ByVal pps As LongPtr, _
ByVal ppd As LongPtr, _
ByVal pdff As Long, _
ByVal ppszDisplay As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PSFormatPropertyValue = ctypes.windll.propsys.PSFormatPropertyValue
PSFormatPropertyValue.restype = ctypes.c_int
PSFormatPropertyValue.argtypes = [
ctypes.c_void_p, # pps : IPropertyStore*
ctypes.c_void_p, # ppd : IPropertyDescription*
ctypes.c_int, # pdff : PROPDESC_FORMAT_FLAGS
ctypes.c_void_p, # ppszDisplay : LPWSTR* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('PROPSYS.dll')
PSFormatPropertyValue = Fiddle::Function.new(
lib['PSFormatPropertyValue'],
[
Fiddle::TYPE_VOIDP, # pps : IPropertyStore*
Fiddle::TYPE_VOIDP, # ppd : IPropertyDescription*
Fiddle::TYPE_INT, # pdff : PROPDESC_FORMAT_FLAGS
Fiddle::TYPE_VOIDP, # ppszDisplay : LPWSTR* out
],
Fiddle::TYPE_INT)#[link(name = "propsys")]
extern "system" {
fn PSFormatPropertyValue(
pps: *mut core::ffi::c_void, // IPropertyStore*
ppd: *mut core::ffi::c_void, // IPropertyDescription*
pdff: i32, // PROPDESC_FORMAT_FLAGS
ppszDisplay: *mut *mut u16 // LPWSTR* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("PROPSYS.dll")]
public static extern int PSFormatPropertyValue(IntPtr pps, IntPtr ppd, int pdff, IntPtr ppszDisplay);
"@
$api = Add-Type -MemberDefinition $sig -Name 'PROPSYS_PSFormatPropertyValue' -Namespace Win32 -PassThru
# $api::PSFormatPropertyValue(pps, ppd, pdff, ppszDisplay)#uselib "PROPSYS.dll"
#func global PSFormatPropertyValue "PSFormatPropertyValue" sptr, sptr, sptr, sptr
; PSFormatPropertyValue pps, ppd, pdff, varptr(ppszDisplay) ; 戻り値は stat
; pps : IPropertyStore* -> "sptr"
; ppd : IPropertyDescription* -> "sptr"
; pdff : PROPDESC_FORMAT_FLAGS -> "sptr"
; ppszDisplay : LPWSTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "PROPSYS.dll" #cfunc global PSFormatPropertyValue "PSFormatPropertyValue" sptr, sptr, int, var ; res = PSFormatPropertyValue(pps, ppd, pdff, ppszDisplay) ; pps : IPropertyStore* -> "sptr" ; ppd : IPropertyDescription* -> "sptr" ; pdff : PROPDESC_FORMAT_FLAGS -> "int" ; ppszDisplay : LPWSTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "PROPSYS.dll" #cfunc global PSFormatPropertyValue "PSFormatPropertyValue" sptr, sptr, int, sptr ; res = PSFormatPropertyValue(pps, ppd, pdff, varptr(ppszDisplay)) ; pps : IPropertyStore* -> "sptr" ; ppd : IPropertyDescription* -> "sptr" ; pdff : PROPDESC_FORMAT_FLAGS -> "int" ; ppszDisplay : LPWSTR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT PSFormatPropertyValue(IPropertyStore* pps, IPropertyDescription* ppd, PROPDESC_FORMAT_FLAGS pdff, LPWSTR* ppszDisplay) #uselib "PROPSYS.dll" #cfunc global PSFormatPropertyValue "PSFormatPropertyValue" intptr, intptr, int, var ; res = PSFormatPropertyValue(pps, ppd, pdff, ppszDisplay) ; pps : IPropertyStore* -> "intptr" ; ppd : IPropertyDescription* -> "intptr" ; pdff : PROPDESC_FORMAT_FLAGS -> "int" ; ppszDisplay : LPWSTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT PSFormatPropertyValue(IPropertyStore* pps, IPropertyDescription* ppd, PROPDESC_FORMAT_FLAGS pdff, LPWSTR* ppszDisplay) #uselib "PROPSYS.dll" #cfunc global PSFormatPropertyValue "PSFormatPropertyValue" intptr, intptr, int, intptr ; res = PSFormatPropertyValue(pps, ppd, pdff, varptr(ppszDisplay)) ; pps : IPropertyStore* -> "intptr" ; ppd : IPropertyDescription* -> "intptr" ; pdff : PROPDESC_FORMAT_FLAGS -> "int" ; ppszDisplay : LPWSTR* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
propsys = windows.NewLazySystemDLL("PROPSYS.dll")
procPSFormatPropertyValue = propsys.NewProc("PSFormatPropertyValue")
)
// pps (IPropertyStore*), ppd (IPropertyDescription*), pdff (PROPDESC_FORMAT_FLAGS), ppszDisplay (LPWSTR* out)
r1, _, err := procPSFormatPropertyValue.Call(
uintptr(pps),
uintptr(ppd),
uintptr(pdff),
uintptr(ppszDisplay),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction PSFormatPropertyValue(
pps: Pointer; // IPropertyStore*
ppd: Pointer; // IPropertyDescription*
pdff: Integer; // PROPDESC_FORMAT_FLAGS
ppszDisplay: PPWideChar // LPWSTR* out
): Integer; stdcall;
external 'PROPSYS.dll' name 'PSFormatPropertyValue';result := DllCall("PROPSYS\PSFormatPropertyValue"
, "Ptr", pps ; IPropertyStore*
, "Ptr", ppd ; IPropertyDescription*
, "Int", pdff ; PROPDESC_FORMAT_FLAGS
, "Ptr", ppszDisplay ; LPWSTR* out
, "Int") ; return: HRESULT●PSFormatPropertyValue(pps, ppd, pdff, ppszDisplay) = DLL("PROPSYS.dll", "int PSFormatPropertyValue(void*, void*, int, void*)")
# 呼び出し: PSFormatPropertyValue(pps, ppd, pdff, ppszDisplay)
# pps : IPropertyStore* -> "void*"
# ppd : IPropertyDescription* -> "void*"
# pdff : PROPDESC_FORMAT_FLAGS -> "int"
# ppszDisplay : LPWSTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "propsys" fn PSFormatPropertyValue(
pps: ?*anyopaque, // IPropertyStore*
ppd: ?*anyopaque, // IPropertyDescription*
pdff: i32, // PROPDESC_FORMAT_FLAGS
ppszDisplay: [*c][*c]u16 // LPWSTR* out
) callconv(std.os.windows.WINAPI) i32;proc PSFormatPropertyValue(
pps: pointer, # IPropertyStore*
ppd: pointer, # IPropertyDescription*
pdff: int32, # PROPDESC_FORMAT_FLAGS
ppszDisplay: ptr WideCString # LPWSTR* out
): int32 {.importc: "PSFormatPropertyValue", stdcall, dynlib: "PROPSYS.dll".}pragma(lib, "propsys");
extern(Windows)
int PSFormatPropertyValue(
void* pps, // IPropertyStore*
void* ppd, // IPropertyDescription*
int pdff, // PROPDESC_FORMAT_FLAGS
wchar** ppszDisplay // LPWSTR* out
);ccall((:PSFormatPropertyValue, "PROPSYS.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, Int32, Ptr{Ptr{UInt16}}),
pps, ppd, pdff, ppszDisplay)
# pps : IPropertyStore* -> Ptr{Cvoid}
# ppd : IPropertyDescription* -> Ptr{Cvoid}
# pdff : PROPDESC_FORMAT_FLAGS -> Int32
# ppszDisplay : LPWSTR* out -> Ptr{Ptr{UInt16}}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t PSFormatPropertyValue(
void* pps,
void* ppd,
int32_t pdff,
uint16_t** ppszDisplay);
]]
local propsys = ffi.load("propsys")
-- propsys.PSFormatPropertyValue(pps, ppd, pdff, ppszDisplay)
-- pps : IPropertyStore*
-- ppd : IPropertyDescription*
-- pdff : PROPDESC_FORMAT_FLAGS
-- ppszDisplay : LPWSTR* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('PROPSYS.dll');
const PSFormatPropertyValue = lib.func('__stdcall', 'PSFormatPropertyValue', 'int32_t', ['void *', 'void *', 'int32_t', 'void *']);
// PSFormatPropertyValue(pps, ppd, pdff, ppszDisplay)
// pps : IPropertyStore* -> 'void *'
// ppd : IPropertyDescription* -> 'void *'
// pdff : PROPDESC_FORMAT_FLAGS -> 'int32_t'
// ppszDisplay : LPWSTR* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("PROPSYS.dll", {
PSFormatPropertyValue: { parameters: ["pointer", "pointer", "i32", "pointer"], result: "i32" },
});
// lib.symbols.PSFormatPropertyValue(pps, ppd, pdff, ppszDisplay)
// pps : IPropertyStore* -> "pointer"
// ppd : IPropertyDescription* -> "pointer"
// pdff : PROPDESC_FORMAT_FLAGS -> "i32"
// ppszDisplay : LPWSTR* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t PSFormatPropertyValue(
void* pps,
void* ppd,
int32_t pdff,
uint16_t** ppszDisplay);
C, "PROPSYS.dll");
// $ffi->PSFormatPropertyValue(pps, ppd, pdff, ppszDisplay);
// pps : IPropertyStore*
// ppd : IPropertyDescription*
// pdff : PROPDESC_FORMAT_FLAGS
// ppszDisplay : LPWSTR* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Propsys extends StdCallLibrary {
Propsys INSTANCE = Native.load("propsys", Propsys.class);
int PSFormatPropertyValue(
Pointer pps, // IPropertyStore*
Pointer ppd, // IPropertyDescription*
int pdff, // PROPDESC_FORMAT_FLAGS
PointerByReference ppszDisplay // LPWSTR* out
);
}@[Link("propsys")]
lib LibPROPSYS
fun PSFormatPropertyValue = PSFormatPropertyValue(
pps : Void*, # IPropertyStore*
ppd : Void*, # IPropertyDescription*
pdff : Int32, # PROPDESC_FORMAT_FLAGS
ppszDisplay : UInt16** # LPWSTR* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef PSFormatPropertyValueNative = Int32 Function(Pointer<Void>, Pointer<Void>, Int32, Pointer<Pointer<Utf16>>);
typedef PSFormatPropertyValueDart = int Function(Pointer<Void>, Pointer<Void>, int, Pointer<Pointer<Utf16>>);
final PSFormatPropertyValue = DynamicLibrary.open('PROPSYS.dll')
.lookupFunction<PSFormatPropertyValueNative, PSFormatPropertyValueDart>('PSFormatPropertyValue');
// pps : IPropertyStore* -> Pointer<Void>
// ppd : IPropertyDescription* -> Pointer<Void>
// pdff : PROPDESC_FORMAT_FLAGS -> Int32
// ppszDisplay : LPWSTR* out -> Pointer<Pointer<Utf16>>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function PSFormatPropertyValue(
pps: Pointer; // IPropertyStore*
ppd: Pointer; // IPropertyDescription*
pdff: Integer; // PROPDESC_FORMAT_FLAGS
ppszDisplay: PPWideChar // LPWSTR* out
): Integer; stdcall;
external 'PROPSYS.dll' name 'PSFormatPropertyValue';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "PSFormatPropertyValue"
c_PSFormatPropertyValue :: Ptr () -> Ptr () -> Int32 -> Ptr CWString -> IO Int32
-- pps : IPropertyStore* -> Ptr ()
-- ppd : IPropertyDescription* -> Ptr ()
-- pdff : PROPDESC_FORMAT_FLAGS -> Int32
-- ppszDisplay : LPWSTR* out -> Ptr CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let psformatpropertyvalue =
foreign "PSFormatPropertyValue"
((ptr void) @-> (ptr void) @-> int32_t @-> (ptr (ptr uint16_t)) @-> returning int32_t)
(* pps : IPropertyStore* -> (ptr void) *)
(* ppd : IPropertyDescription* -> (ptr void) *)
(* pdff : PROPDESC_FORMAT_FLAGS -> int32_t *)
(* ppszDisplay : LPWSTR* out -> (ptr (ptr uint16_t)) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library propsys (t "PROPSYS.dll"))
(cffi:use-foreign-library propsys)
(cffi:defcfun ("PSFormatPropertyValue" psformat-property-value :convention :stdcall) :int32
(pps :pointer) ; IPropertyStore*
(ppd :pointer) ; IPropertyDescription*
(pdff :int32) ; PROPDESC_FORMAT_FLAGS
(ppsz-display :pointer)) ; LPWSTR* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $PSFormatPropertyValue = Win32::API::More->new('PROPSYS',
'int PSFormatPropertyValue(LPVOID pps, LPVOID ppd, int pdff, LPVOID ppszDisplay)');
# my $ret = $PSFormatPropertyValue->Call($pps, $ppd, $pdff, $ppszDisplay);
# pps : IPropertyStore* -> LPVOID
# ppd : IPropertyDescription* -> LPVOID
# pdff : PROPDESC_FORMAT_FLAGS -> int
# ppszDisplay : LPWSTR* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。