Win32 API 日本語リファレンス
ホームNetworking.Clustering › ResUtilFindSzProperty

ResUtilFindSzProperty

関数
プロパティリストから文字列プロパティを名前で検索する。
DLLRESUTILS.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

DWORD ResUtilFindSzProperty(
    const void* pPropertyList,
    DWORD cbPropertyListSize,
    LPCWSTR pszPropertyName,
    LPWSTR* pszPropertyValue   // optional
);

パラメーター

名前方向説明
pPropertyListvoid*in検索対象のプロパティリストバッファーへのポインター。
cbPropertyListSizeDWORDinプロパティリストの総バイト数。
pszPropertyNameLPCWSTRin検索する文字列(SZ)プロパティの名前。
pszPropertyValueLPWSTR*outoptional見つかった文字列値を受け取るポインターのアドレス。新規確保され返る。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD ResUtilFindSzProperty(
    const void* pPropertyList,
    DWORD cbPropertyListSize,
    LPCWSTR pszPropertyName,
    LPWSTR* pszPropertyValue   // optional
);
[DllImport("RESUTILS.dll", ExactSpelling = true)]
static extern uint ResUtilFindSzProperty(
    IntPtr pPropertyList,   // void*
    uint cbPropertyListSize,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string pszPropertyName,   // LPCWSTR
    IntPtr pszPropertyValue   // LPWSTR* optional, out
);
<DllImport("RESUTILS.dll", ExactSpelling:=True)>
Public Shared Function ResUtilFindSzProperty(
    pPropertyList As IntPtr,   ' void*
    cbPropertyListSize As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> pszPropertyName As String,   ' LPCWSTR
    pszPropertyValue As IntPtr   ' LPWSTR* optional, out
) As UInteger
End Function
' pPropertyList : void*
' cbPropertyListSize : DWORD
' pszPropertyName : LPCWSTR
' pszPropertyValue : LPWSTR* optional, out
Declare PtrSafe Function ResUtilFindSzProperty Lib "resutils" ( _
    ByVal pPropertyList As LongPtr, _
    ByVal cbPropertyListSize As Long, _
    ByVal pszPropertyName As LongPtr, _
    ByVal pszPropertyValue As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ResUtilFindSzProperty = ctypes.windll.resutils.ResUtilFindSzProperty
ResUtilFindSzProperty.restype = wintypes.DWORD
ResUtilFindSzProperty.argtypes = [
    ctypes.POINTER(None),  # pPropertyList : void*
    wintypes.DWORD,  # cbPropertyListSize : DWORD
    wintypes.LPCWSTR,  # pszPropertyName : LPCWSTR
    ctypes.c_void_p,  # pszPropertyValue : LPWSTR* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RESUTILS.dll')
ResUtilFindSzProperty = Fiddle::Function.new(
  lib['ResUtilFindSzProperty'],
  [
    Fiddle::TYPE_VOIDP,  # pPropertyList : void*
    -Fiddle::TYPE_INT,  # cbPropertyListSize : DWORD
    Fiddle::TYPE_VOIDP,  # pszPropertyName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pszPropertyValue : LPWSTR* optional, out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "resutils")]
extern "system" {
    fn ResUtilFindSzProperty(
        pPropertyList: *const (),  // void*
        cbPropertyListSize: u32,  // DWORD
        pszPropertyName: *const u16,  // LPCWSTR
        pszPropertyValue: *mut *mut u16  // LPWSTR* optional, out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RESUTILS.dll")]
public static extern uint ResUtilFindSzProperty(IntPtr pPropertyList, uint cbPropertyListSize, [MarshalAs(UnmanagedType.LPWStr)] string pszPropertyName, IntPtr pszPropertyValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RESUTILS_ResUtilFindSzProperty' -Namespace Win32 -PassThru
# $api::ResUtilFindSzProperty(pPropertyList, cbPropertyListSize, pszPropertyName, pszPropertyValue)
#uselib "RESUTILS.dll"
#func global ResUtilFindSzProperty "ResUtilFindSzProperty" sptr, sptr, sptr, sptr
; ResUtilFindSzProperty pPropertyList, cbPropertyListSize, pszPropertyName, varptr(pszPropertyValue)   ; 戻り値は stat
; pPropertyList : void* -> "sptr"
; cbPropertyListSize : DWORD -> "sptr"
; pszPropertyName : LPCWSTR -> "sptr"
; pszPropertyValue : LPWSTR* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "RESUTILS.dll"
#cfunc global ResUtilFindSzProperty "ResUtilFindSzProperty" sptr, int, wstr, var
; res = ResUtilFindSzProperty(pPropertyList, cbPropertyListSize, pszPropertyName, pszPropertyValue)
; pPropertyList : void* -> "sptr"
; cbPropertyListSize : DWORD -> "int"
; pszPropertyName : LPCWSTR -> "wstr"
; pszPropertyValue : LPWSTR* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD ResUtilFindSzProperty(void* pPropertyList, DWORD cbPropertyListSize, LPCWSTR pszPropertyName, LPWSTR* pszPropertyValue)
#uselib "RESUTILS.dll"
#cfunc global ResUtilFindSzProperty "ResUtilFindSzProperty" intptr, int, wstr, var
; res = ResUtilFindSzProperty(pPropertyList, cbPropertyListSize, pszPropertyName, pszPropertyValue)
; pPropertyList : void* -> "intptr"
; cbPropertyListSize : DWORD -> "int"
; pszPropertyName : LPCWSTR -> "wstr"
; pszPropertyValue : LPWSTR* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	resutils = windows.NewLazySystemDLL("RESUTILS.dll")
	procResUtilFindSzProperty = resutils.NewProc("ResUtilFindSzProperty")
)

// pPropertyList (void*), cbPropertyListSize (DWORD), pszPropertyName (LPCWSTR), pszPropertyValue (LPWSTR* optional, out)
r1, _, err := procResUtilFindSzProperty.Call(
	uintptr(pPropertyList),
	uintptr(cbPropertyListSize),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszPropertyName))),
	uintptr(pszPropertyValue),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function ResUtilFindSzProperty(
  pPropertyList: Pointer;   // void*
  cbPropertyListSize: DWORD;   // DWORD
  pszPropertyName: PWideChar;   // LPCWSTR
  pszPropertyValue: PPWideChar   // LPWSTR* optional, out
): DWORD; stdcall;
  external 'RESUTILS.dll' name 'ResUtilFindSzProperty';
result := DllCall("RESUTILS\ResUtilFindSzProperty"
    , "Ptr", pPropertyList   ; void*
    , "UInt", cbPropertyListSize   ; DWORD
    , "WStr", pszPropertyName   ; LPCWSTR
    , "Ptr", pszPropertyValue   ; LPWSTR* optional, out
    , "UInt")   ; return: DWORD
●ResUtilFindSzProperty(pPropertyList, cbPropertyListSize, pszPropertyName, pszPropertyValue) = DLL("RESUTILS.dll", "dword ResUtilFindSzProperty(void*, dword, char*, void*)")
# 呼び出し: ResUtilFindSzProperty(pPropertyList, cbPropertyListSize, pszPropertyName, pszPropertyValue)
# pPropertyList : void* -> "void*"
# cbPropertyListSize : DWORD -> "dword"
# pszPropertyName : LPCWSTR -> "char*"
# pszPropertyValue : LPWSTR* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "resutils" fn ResUtilFindSzProperty(
    pPropertyList: ?*anyopaque, // void*
    cbPropertyListSize: u32, // DWORD
    pszPropertyName: [*c]const u16, // LPCWSTR
    pszPropertyValue: [*c][*c]u16 // LPWSTR* optional, out
) callconv(std.os.windows.WINAPI) u32;
proc ResUtilFindSzProperty(
    pPropertyList: pointer,  # void*
    cbPropertyListSize: uint32,  # DWORD
    pszPropertyName: WideCString,  # LPCWSTR
    pszPropertyValue: ptr WideCString  # LPWSTR* optional, out
): uint32 {.importc: "ResUtilFindSzProperty", stdcall, dynlib: "RESUTILS.dll".}
pragma(lib, "resutils");
extern(Windows)
uint ResUtilFindSzProperty(
    void* pPropertyList,   // void*
    uint cbPropertyListSize,   // DWORD
    const(wchar)* pszPropertyName,   // LPCWSTR
    wchar** pszPropertyValue   // LPWSTR* optional, out
);
ccall((:ResUtilFindSzProperty, "RESUTILS.dll"), stdcall, UInt32,
      (Ptr{Cvoid}, UInt32, Cwstring, Ptr{Ptr{UInt16}}),
      pPropertyList, cbPropertyListSize, pszPropertyName, pszPropertyValue)
# pPropertyList : void* -> Ptr{Cvoid}
# cbPropertyListSize : DWORD -> UInt32
# pszPropertyName : LPCWSTR -> Cwstring
# pszPropertyValue : LPWSTR* optional, out -> Ptr{Ptr{UInt16}}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t ResUtilFindSzProperty(
    void* pPropertyList,
    uint32_t cbPropertyListSize,
    const uint16_t* pszPropertyName,
    uint16_t** pszPropertyValue);
]]
local resutils = ffi.load("resutils")
-- resutils.ResUtilFindSzProperty(pPropertyList, cbPropertyListSize, pszPropertyName, pszPropertyValue)
-- pPropertyList : void*
-- cbPropertyListSize : DWORD
-- pszPropertyName : LPCWSTR
-- pszPropertyValue : LPWSTR* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('RESUTILS.dll');
const ResUtilFindSzProperty = lib.func('__stdcall', 'ResUtilFindSzProperty', 'uint32_t', ['void *', 'uint32_t', 'str16', 'void *']);
// ResUtilFindSzProperty(pPropertyList, cbPropertyListSize, pszPropertyName, pszPropertyValue)
// pPropertyList : void* -> 'void *'
// cbPropertyListSize : DWORD -> 'uint32_t'
// pszPropertyName : LPCWSTR -> 'str16'
// pszPropertyValue : LPWSTR* optional, out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("RESUTILS.dll", {
  ResUtilFindSzProperty: { parameters: ["pointer", "u32", "buffer", "pointer"], result: "u32" },
});
// lib.symbols.ResUtilFindSzProperty(pPropertyList, cbPropertyListSize, pszPropertyName, pszPropertyValue)
// pPropertyList : void* -> "pointer"
// cbPropertyListSize : DWORD -> "u32"
// pszPropertyName : LPCWSTR -> "buffer"
// pszPropertyValue : LPWSTR* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t ResUtilFindSzProperty(
    void* pPropertyList,
    uint32_t cbPropertyListSize,
    const uint16_t* pszPropertyName,
    uint16_t** pszPropertyValue);
C, "RESUTILS.dll");
// $ffi->ResUtilFindSzProperty(pPropertyList, cbPropertyListSize, pszPropertyName, pszPropertyValue);
// pPropertyList : void*
// cbPropertyListSize : DWORD
// pszPropertyName : LPCWSTR
// pszPropertyValue : LPWSTR* optional, 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 Resutils extends StdCallLibrary {
    Resutils INSTANCE = Native.load("resutils", Resutils.class);
    int ResUtilFindSzProperty(
        Pointer pPropertyList,   // void*
        int cbPropertyListSize,   // DWORD
        WString pszPropertyName,   // LPCWSTR
        PointerByReference pszPropertyValue   // LPWSTR* optional, out
    );
}
@[Link("resutils")]
lib LibRESUTILS
  fun ResUtilFindSzProperty = ResUtilFindSzProperty(
    pPropertyList : Void*,   # void*
    cbPropertyListSize : UInt32,   # DWORD
    pszPropertyName : UInt16*,   # LPCWSTR
    pszPropertyValue : UInt16**   # LPWSTR* optional, out
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ResUtilFindSzPropertyNative = Uint32 Function(Pointer<Void>, Uint32, Pointer<Utf16>, Pointer<Pointer<Utf16>>);
typedef ResUtilFindSzPropertyDart = int Function(Pointer<Void>, int, Pointer<Utf16>, Pointer<Pointer<Utf16>>);
final ResUtilFindSzProperty = DynamicLibrary.open('RESUTILS.dll')
    .lookupFunction<ResUtilFindSzPropertyNative, ResUtilFindSzPropertyDart>('ResUtilFindSzProperty');
// pPropertyList : void* -> Pointer<Void>
// cbPropertyListSize : DWORD -> Uint32
// pszPropertyName : LPCWSTR -> Pointer<Utf16>
// pszPropertyValue : LPWSTR* optional, out -> Pointer<Pointer<Utf16>>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ResUtilFindSzProperty(
  pPropertyList: Pointer;   // void*
  cbPropertyListSize: DWORD;   // DWORD
  pszPropertyName: PWideChar;   // LPCWSTR
  pszPropertyValue: PPWideChar   // LPWSTR* optional, out
): DWORD; stdcall;
  external 'RESUTILS.dll' name 'ResUtilFindSzProperty';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ResUtilFindSzProperty"
  c_ResUtilFindSzProperty :: Ptr () -> Word32 -> CWString -> Ptr CWString -> IO Word32
-- pPropertyList : void* -> Ptr ()
-- cbPropertyListSize : DWORD -> Word32
-- pszPropertyName : LPCWSTR -> CWString
-- pszPropertyValue : LPWSTR* optional, out -> Ptr CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let resutilfindszproperty =
  foreign "ResUtilFindSzProperty"
    ((ptr void) @-> uint32_t @-> (ptr uint16_t) @-> (ptr (ptr uint16_t)) @-> returning uint32_t)
(* pPropertyList : void* -> (ptr void) *)
(* cbPropertyListSize : DWORD -> uint32_t *)
(* pszPropertyName : LPCWSTR -> (ptr uint16_t) *)
(* pszPropertyValue : LPWSTR* optional, out -> (ptr (ptr uint16_t)) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library resutils (t "RESUTILS.dll"))
(cffi:use-foreign-library resutils)

(cffi:defcfun ("ResUtilFindSzProperty" res-util-find-sz-property :convention :stdcall) :uint32
  (p-property-list :pointer)   ; void*
  (cb-property-list-size :uint32)   ; DWORD
  (psz-property-name (:string :encoding :utf-16le))   ; LPCWSTR
  (psz-property-value :pointer))   ; LPWSTR* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ResUtilFindSzProperty = Win32::API::More->new('RESUTILS',
    'DWORD ResUtilFindSzProperty(LPVOID pPropertyList, DWORD cbPropertyListSize, LPCWSTR pszPropertyName, LPVOID pszPropertyValue)');
# my $ret = $ResUtilFindSzProperty->Call($pPropertyList, $cbPropertyListSize, $pszPropertyName, $pszPropertyValue);
# pPropertyList : void* -> LPVOID
# cbPropertyListSize : DWORD -> DWORD
# pszPropertyName : LPCWSTR -> LPCWSTR
# pszPropertyValue : LPWSTR* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。