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