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

ResUtilGetProperty

関数
単一プロパティ項目の値を取得する。
DLLRESUTILS.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

DWORD ResUtilGetProperty(
    HKEY hkeyClusterKey,
    const RESUTIL_PROPERTY_ITEM* pPropertyTableItem,
    void** pOutPropertyItem,
    DWORD* pcbOutPropertyItemSize
);

パラメーター

名前方向説明
hkeyClusterKeyHKEYin単一プロパティを取得する対象のクラスターレジストリキー。
pPropertyTableItemRESUTIL_PROPERTY_ITEM*in取得する単一プロパティ定義のRESUTIL_PROPERTY_ITEMポインタ。
pOutPropertyItemvoid**inout取得したプロパティ項目バッファを受け取るポインタのポインタ。
pcbOutPropertyItemSizeDWORD*inout取得した項目のバイト数を受け取るDWORDポインタ。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD ResUtilGetProperty(
    HKEY hkeyClusterKey,
    const RESUTIL_PROPERTY_ITEM* pPropertyTableItem,
    void** pOutPropertyItem,
    DWORD* pcbOutPropertyItemSize
);
[DllImport("RESUTILS.dll", ExactSpelling = true)]
static extern uint ResUtilGetProperty(
    IntPtr hkeyClusterKey,   // HKEY
    IntPtr pPropertyTableItem,   // RESUTIL_PROPERTY_ITEM*
    IntPtr pOutPropertyItem,   // void** in/out
    ref uint pcbOutPropertyItemSize   // DWORD* in/out
);
<DllImport("RESUTILS.dll", ExactSpelling:=True)>
Public Shared Function ResUtilGetProperty(
    hkeyClusterKey As IntPtr,   ' HKEY
    pPropertyTableItem As IntPtr,   ' RESUTIL_PROPERTY_ITEM*
    pOutPropertyItem As IntPtr,   ' void** in/out
    ByRef pcbOutPropertyItemSize As UInteger   ' DWORD* in/out
) As UInteger
End Function
' hkeyClusterKey : HKEY
' pPropertyTableItem : RESUTIL_PROPERTY_ITEM*
' pOutPropertyItem : void** in/out
' pcbOutPropertyItemSize : DWORD* in/out
Declare PtrSafe Function ResUtilGetProperty Lib "resutils" ( _
    ByVal hkeyClusterKey As LongPtr, _
    ByVal pPropertyTableItem As LongPtr, _
    ByVal pOutPropertyItem As LongPtr, _
    ByRef pcbOutPropertyItemSize As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ResUtilGetProperty = ctypes.windll.resutils.ResUtilGetProperty
ResUtilGetProperty.restype = wintypes.DWORD
ResUtilGetProperty.argtypes = [
    wintypes.HANDLE,  # hkeyClusterKey : HKEY
    ctypes.c_void_p,  # pPropertyTableItem : RESUTIL_PROPERTY_ITEM*
    ctypes.c_void_p,  # pOutPropertyItem : void** in/out
    ctypes.POINTER(wintypes.DWORD),  # pcbOutPropertyItemSize : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	resutils = windows.NewLazySystemDLL("RESUTILS.dll")
	procResUtilGetProperty = resutils.NewProc("ResUtilGetProperty")
)

// hkeyClusterKey (HKEY), pPropertyTableItem (RESUTIL_PROPERTY_ITEM*), pOutPropertyItem (void** in/out), pcbOutPropertyItemSize (DWORD* in/out)
r1, _, err := procResUtilGetProperty.Call(
	uintptr(hkeyClusterKey),
	uintptr(pPropertyTableItem),
	uintptr(pOutPropertyItem),
	uintptr(pcbOutPropertyItemSize),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function ResUtilGetProperty(
  hkeyClusterKey: THandle;   // HKEY
  pPropertyTableItem: Pointer;   // RESUTIL_PROPERTY_ITEM*
  pOutPropertyItem: Pointer;   // void** in/out
  pcbOutPropertyItemSize: Pointer   // DWORD* in/out
): DWORD; stdcall;
  external 'RESUTILS.dll' name 'ResUtilGetProperty';
result := DllCall("RESUTILS\ResUtilGetProperty"
    , "Ptr", hkeyClusterKey   ; HKEY
    , "Ptr", pPropertyTableItem   ; RESUTIL_PROPERTY_ITEM*
    , "Ptr", pOutPropertyItem   ; void** in/out
    , "Ptr", pcbOutPropertyItemSize   ; DWORD* in/out
    , "UInt")   ; return: DWORD
●ResUtilGetProperty(hkeyClusterKey, pPropertyTableItem, pOutPropertyItem, pcbOutPropertyItemSize) = DLL("RESUTILS.dll", "dword ResUtilGetProperty(void*, void*, void*, void*)")
# 呼び出し: ResUtilGetProperty(hkeyClusterKey, pPropertyTableItem, pOutPropertyItem, pcbOutPropertyItemSize)
# hkeyClusterKey : HKEY -> "void*"
# pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> "void*"
# pOutPropertyItem : void** in/out -> "void*"
# pcbOutPropertyItemSize : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef ResUtilGetPropertyNative = Uint32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Uint32>);
typedef ResUtilGetPropertyDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Uint32>);
final ResUtilGetProperty = DynamicLibrary.open('RESUTILS.dll')
    .lookupFunction<ResUtilGetPropertyNative, ResUtilGetPropertyDart>('ResUtilGetProperty');
// hkeyClusterKey : HKEY -> Pointer<Void>
// pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> Pointer<Void>
// pOutPropertyItem : void** in/out -> Pointer<Void>
// pcbOutPropertyItemSize : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ResUtilGetProperty(
  hkeyClusterKey: THandle;   // HKEY
  pPropertyTableItem: Pointer;   // RESUTIL_PROPERTY_ITEM*
  pOutPropertyItem: Pointer;   // void** in/out
  pcbOutPropertyItemSize: Pointer   // DWORD* in/out
): DWORD; stdcall;
  external 'RESUTILS.dll' name 'ResUtilGetProperty';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ResUtilGetProperty"
  c_ResUtilGetProperty :: Ptr () -> Ptr () -> Ptr () -> Ptr Word32 -> IO Word32
-- hkeyClusterKey : HKEY -> Ptr ()
-- pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> Ptr ()
-- pOutPropertyItem : void** in/out -> Ptr ()
-- pcbOutPropertyItemSize : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let resutilgetproperty =
  foreign "ResUtilGetProperty"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr uint32_t) @-> returning uint32_t)
(* hkeyClusterKey : HKEY -> (ptr void) *)
(* pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> (ptr void) *)
(* pOutPropertyItem : void** in/out -> (ptr void) *)
(* pcbOutPropertyItemSize : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library resutils (t "RESUTILS.dll"))
(cffi:use-foreign-library resutils)

(cffi:defcfun ("ResUtilGetProperty" res-util-get-property :convention :stdcall) :uint32
  (hkey-cluster-key :pointer)   ; HKEY
  (p-property-table-item :pointer)   ; RESUTIL_PROPERTY_ITEM*
  (p-out-property-item :pointer)   ; void** in/out
  (pcb-out-property-item-size :pointer))   ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ResUtilGetProperty = Win32::API::More->new('RESUTILS',
    'DWORD ResUtilGetProperty(HANDLE hkeyClusterKey, LPVOID pPropertyTableItem, LPVOID pOutPropertyItem, LPVOID pcbOutPropertyItemSize)');
# my $ret = $ResUtilGetProperty->Call($hkeyClusterKey, $pPropertyTableItem, $pOutPropertyItem, $pcbOutPropertyItemSize);
# hkeyClusterKey : HKEY -> HANDLE
# pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> LPVOID
# pOutPropertyItem : void** in/out -> LPVOID
# pcbOutPropertyItemSize : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型