ホーム › UI.Shell.PropertiesSystem › PSStringFromPropertyKey
PSStringFromPropertyKey
関数プロパティキーを文字列形式に変換する。
シグネチャ
// PROPSYS.dll
#include <windows.h>
HRESULT PSStringFromPropertyKey(
const PROPERTYKEY* pkey,
LPWSTR psz,
DWORD cch
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pkey | PROPERTYKEY* | in |
| psz | LPWSTR | out |
| cch | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// PROPSYS.dll
#include <windows.h>
HRESULT PSStringFromPropertyKey(
const PROPERTYKEY* pkey,
LPWSTR psz,
DWORD cch
);[DllImport("PROPSYS.dll", ExactSpelling = true)]
static extern int PSStringFromPropertyKey(
IntPtr pkey, // PROPERTYKEY*
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder psz, // LPWSTR out
uint cch // DWORD
);<DllImport("PROPSYS.dll", ExactSpelling:=True)>
Public Shared Function PSStringFromPropertyKey(
pkey As IntPtr, ' PROPERTYKEY*
<MarshalAs(UnmanagedType.LPWStr)> psz As System.Text.StringBuilder, ' LPWSTR out
cch As UInteger ' DWORD
) As Integer
End Function' pkey : PROPERTYKEY*
' psz : LPWSTR out
' cch : DWORD
Declare PtrSafe Function PSStringFromPropertyKey Lib "propsys" ( _
ByVal pkey As LongPtr, _
ByVal psz As LongPtr, _
ByVal cch As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PSStringFromPropertyKey = ctypes.windll.propsys.PSStringFromPropertyKey
PSStringFromPropertyKey.restype = ctypes.c_int
PSStringFromPropertyKey.argtypes = [
ctypes.c_void_p, # pkey : PROPERTYKEY*
wintypes.LPWSTR, # psz : LPWSTR out
wintypes.DWORD, # cch : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('PROPSYS.dll')
PSStringFromPropertyKey = Fiddle::Function.new(
lib['PSStringFromPropertyKey'],
[
Fiddle::TYPE_VOIDP, # pkey : PROPERTYKEY*
Fiddle::TYPE_VOIDP, # psz : LPWSTR out
-Fiddle::TYPE_INT, # cch : DWORD
],
Fiddle::TYPE_INT)#[link(name = "propsys")]
extern "system" {
fn PSStringFromPropertyKey(
pkey: *const PROPERTYKEY, // PROPERTYKEY*
psz: *mut u16, // LPWSTR out
cch: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("PROPSYS.dll")]
public static extern int PSStringFromPropertyKey(IntPtr pkey, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder psz, uint cch);
"@
$api = Add-Type -MemberDefinition $sig -Name 'PROPSYS_PSStringFromPropertyKey' -Namespace Win32 -PassThru
# $api::PSStringFromPropertyKey(pkey, psz, cch)#uselib "PROPSYS.dll"
#func global PSStringFromPropertyKey "PSStringFromPropertyKey" sptr, sptr, sptr
; PSStringFromPropertyKey varptr(pkey), varptr(psz), cch ; 戻り値は stat
; pkey : PROPERTYKEY* -> "sptr"
; psz : LPWSTR out -> "sptr"
; cch : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "PROPSYS.dll" #cfunc global PSStringFromPropertyKey "PSStringFromPropertyKey" var, var, int ; res = PSStringFromPropertyKey(pkey, psz, cch) ; pkey : PROPERTYKEY* -> "var" ; psz : LPWSTR out -> "var" ; cch : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "PROPSYS.dll" #cfunc global PSStringFromPropertyKey "PSStringFromPropertyKey" sptr, sptr, int ; res = PSStringFromPropertyKey(varptr(pkey), varptr(psz), cch) ; pkey : PROPERTYKEY* -> "sptr" ; psz : LPWSTR out -> "sptr" ; cch : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT PSStringFromPropertyKey(PROPERTYKEY* pkey, LPWSTR psz, DWORD cch) #uselib "PROPSYS.dll" #cfunc global PSStringFromPropertyKey "PSStringFromPropertyKey" var, var, int ; res = PSStringFromPropertyKey(pkey, psz, cch) ; pkey : PROPERTYKEY* -> "var" ; psz : LPWSTR out -> "var" ; cch : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT PSStringFromPropertyKey(PROPERTYKEY* pkey, LPWSTR psz, DWORD cch) #uselib "PROPSYS.dll" #cfunc global PSStringFromPropertyKey "PSStringFromPropertyKey" intptr, intptr, int ; res = PSStringFromPropertyKey(varptr(pkey), varptr(psz), cch) ; pkey : PROPERTYKEY* -> "intptr" ; psz : LPWSTR out -> "intptr" ; cch : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
propsys = windows.NewLazySystemDLL("PROPSYS.dll")
procPSStringFromPropertyKey = propsys.NewProc("PSStringFromPropertyKey")
)
// pkey (PROPERTYKEY*), psz (LPWSTR out), cch (DWORD)
r1, _, err := procPSStringFromPropertyKey.Call(
uintptr(pkey),
uintptr(psz),
uintptr(cch),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction PSStringFromPropertyKey(
pkey: Pointer; // PROPERTYKEY*
psz: PWideChar; // LPWSTR out
cch: DWORD // DWORD
): Integer; stdcall;
external 'PROPSYS.dll' name 'PSStringFromPropertyKey';result := DllCall("PROPSYS\PSStringFromPropertyKey"
, "Ptr", pkey ; PROPERTYKEY*
, "Ptr", psz ; LPWSTR out
, "UInt", cch ; DWORD
, "Int") ; return: HRESULT●PSStringFromPropertyKey(pkey, psz, cch) = DLL("PROPSYS.dll", "int PSStringFromPropertyKey(void*, char*, dword)")
# 呼び出し: PSStringFromPropertyKey(pkey, psz, cch)
# pkey : PROPERTYKEY* -> "void*"
# psz : LPWSTR out -> "char*"
# cch : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。