ホーム › Networking.Clustering › ResUtilGetPropertySize
ResUtilGetPropertySize
関数プロパティリストに必要なバッファサイズと数を算出する。
シグネチャ
// RESUTILS.dll
#include <windows.h>
DWORD ResUtilGetPropertySize(
HKEY hkeyClusterKey,
const RESUTIL_PROPERTY_ITEM* pPropertyTableItem,
DWORD* pcbOutPropertyListSize,
DWORD* pnPropertyCount
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hkeyClusterKey | HKEY | in | プロパティサイズを計算する対象のクラスターレジストリキー。 |
| pPropertyTableItem | RESUTIL_PROPERTY_ITEM* | in | サイズを求める単一プロパティ定義のRESUTIL_PROPERTY_ITEMポインタ。 |
| pcbOutPropertyListSize | DWORD* | inout | 必要なプロパティリストのバイト数を加算して受け取るDWORDポインタ。 |
| pnPropertyCount | DWORD* | inout | プロパティ数を加算して受け取るDWORDポインタ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// RESUTILS.dll
#include <windows.h>
DWORD ResUtilGetPropertySize(
HKEY hkeyClusterKey,
const RESUTIL_PROPERTY_ITEM* pPropertyTableItem,
DWORD* pcbOutPropertyListSize,
DWORD* pnPropertyCount
);[DllImport("RESUTILS.dll", ExactSpelling = true)]
static extern uint ResUtilGetPropertySize(
IntPtr hkeyClusterKey, // HKEY
IntPtr pPropertyTableItem, // RESUTIL_PROPERTY_ITEM*
ref uint pcbOutPropertyListSize, // DWORD* in/out
ref uint pnPropertyCount // DWORD* in/out
);<DllImport("RESUTILS.dll", ExactSpelling:=True)>
Public Shared Function ResUtilGetPropertySize(
hkeyClusterKey As IntPtr, ' HKEY
pPropertyTableItem As IntPtr, ' RESUTIL_PROPERTY_ITEM*
ByRef pcbOutPropertyListSize As UInteger, ' DWORD* in/out
ByRef pnPropertyCount As UInteger ' DWORD* in/out
) As UInteger
End Function' hkeyClusterKey : HKEY
' pPropertyTableItem : RESUTIL_PROPERTY_ITEM*
' pcbOutPropertyListSize : DWORD* in/out
' pnPropertyCount : DWORD* in/out
Declare PtrSafe Function ResUtilGetPropertySize Lib "resutils" ( _
ByVal hkeyClusterKey As LongPtr, _
ByVal pPropertyTableItem As LongPtr, _
ByRef pcbOutPropertyListSize As Long, _
ByRef pnPropertyCount As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ResUtilGetPropertySize = ctypes.windll.resutils.ResUtilGetPropertySize
ResUtilGetPropertySize.restype = wintypes.DWORD
ResUtilGetPropertySize.argtypes = [
wintypes.HANDLE, # hkeyClusterKey : HKEY
ctypes.c_void_p, # pPropertyTableItem : RESUTIL_PROPERTY_ITEM*
ctypes.POINTER(wintypes.DWORD), # pcbOutPropertyListSize : DWORD* in/out
ctypes.POINTER(wintypes.DWORD), # pnPropertyCount : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RESUTILS.dll')
ResUtilGetPropertySize = Fiddle::Function.new(
lib['ResUtilGetPropertySize'],
[
Fiddle::TYPE_VOIDP, # hkeyClusterKey : HKEY
Fiddle::TYPE_VOIDP, # pPropertyTableItem : RESUTIL_PROPERTY_ITEM*
Fiddle::TYPE_VOIDP, # pcbOutPropertyListSize : DWORD* in/out
Fiddle::TYPE_VOIDP, # pnPropertyCount : DWORD* in/out
],
-Fiddle::TYPE_INT)#[link(name = "resutils")]
extern "system" {
fn ResUtilGetPropertySize(
hkeyClusterKey: *mut core::ffi::c_void, // HKEY
pPropertyTableItem: *const RESUTIL_PROPERTY_ITEM, // RESUTIL_PROPERTY_ITEM*
pcbOutPropertyListSize: *mut u32, // DWORD* in/out
pnPropertyCount: *mut u32 // DWORD* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RESUTILS.dll")]
public static extern uint ResUtilGetPropertySize(IntPtr hkeyClusterKey, IntPtr pPropertyTableItem, ref uint pcbOutPropertyListSize, ref uint pnPropertyCount);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RESUTILS_ResUtilGetPropertySize' -Namespace Win32 -PassThru
# $api::ResUtilGetPropertySize(hkeyClusterKey, pPropertyTableItem, pcbOutPropertyListSize, pnPropertyCount)#uselib "RESUTILS.dll"
#func global ResUtilGetPropertySize "ResUtilGetPropertySize" sptr, sptr, sptr, sptr
; ResUtilGetPropertySize hkeyClusterKey, varptr(pPropertyTableItem), varptr(pcbOutPropertyListSize), varptr(pnPropertyCount) ; 戻り値は stat
; hkeyClusterKey : HKEY -> "sptr"
; pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> "sptr"
; pcbOutPropertyListSize : DWORD* in/out -> "sptr"
; pnPropertyCount : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "RESUTILS.dll" #cfunc global ResUtilGetPropertySize "ResUtilGetPropertySize" sptr, var, var, var ; res = ResUtilGetPropertySize(hkeyClusterKey, pPropertyTableItem, pcbOutPropertyListSize, pnPropertyCount) ; hkeyClusterKey : HKEY -> "sptr" ; pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> "var" ; pcbOutPropertyListSize : DWORD* in/out -> "var" ; pnPropertyCount : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RESUTILS.dll" #cfunc global ResUtilGetPropertySize "ResUtilGetPropertySize" sptr, sptr, sptr, sptr ; res = ResUtilGetPropertySize(hkeyClusterKey, varptr(pPropertyTableItem), varptr(pcbOutPropertyListSize), varptr(pnPropertyCount)) ; hkeyClusterKey : HKEY -> "sptr" ; pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> "sptr" ; pcbOutPropertyListSize : DWORD* in/out -> "sptr" ; pnPropertyCount : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD ResUtilGetPropertySize(HKEY hkeyClusterKey, RESUTIL_PROPERTY_ITEM* pPropertyTableItem, DWORD* pcbOutPropertyListSize, DWORD* pnPropertyCount) #uselib "RESUTILS.dll" #cfunc global ResUtilGetPropertySize "ResUtilGetPropertySize" intptr, var, var, var ; res = ResUtilGetPropertySize(hkeyClusterKey, pPropertyTableItem, pcbOutPropertyListSize, pnPropertyCount) ; hkeyClusterKey : HKEY -> "intptr" ; pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> "var" ; pcbOutPropertyListSize : DWORD* in/out -> "var" ; pnPropertyCount : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD ResUtilGetPropertySize(HKEY hkeyClusterKey, RESUTIL_PROPERTY_ITEM* pPropertyTableItem, DWORD* pcbOutPropertyListSize, DWORD* pnPropertyCount) #uselib "RESUTILS.dll" #cfunc global ResUtilGetPropertySize "ResUtilGetPropertySize" intptr, intptr, intptr, intptr ; res = ResUtilGetPropertySize(hkeyClusterKey, varptr(pPropertyTableItem), varptr(pcbOutPropertyListSize), varptr(pnPropertyCount)) ; hkeyClusterKey : HKEY -> "intptr" ; pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> "intptr" ; pcbOutPropertyListSize : DWORD* in/out -> "intptr" ; pnPropertyCount : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
resutils = windows.NewLazySystemDLL("RESUTILS.dll")
procResUtilGetPropertySize = resutils.NewProc("ResUtilGetPropertySize")
)
// hkeyClusterKey (HKEY), pPropertyTableItem (RESUTIL_PROPERTY_ITEM*), pcbOutPropertyListSize (DWORD* in/out), pnPropertyCount (DWORD* in/out)
r1, _, err := procResUtilGetPropertySize.Call(
uintptr(hkeyClusterKey),
uintptr(pPropertyTableItem),
uintptr(pcbOutPropertyListSize),
uintptr(pnPropertyCount),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction ResUtilGetPropertySize(
hkeyClusterKey: THandle; // HKEY
pPropertyTableItem: Pointer; // RESUTIL_PROPERTY_ITEM*
pcbOutPropertyListSize: Pointer; // DWORD* in/out
pnPropertyCount: Pointer // DWORD* in/out
): DWORD; stdcall;
external 'RESUTILS.dll' name 'ResUtilGetPropertySize';result := DllCall("RESUTILS\ResUtilGetPropertySize"
, "Ptr", hkeyClusterKey ; HKEY
, "Ptr", pPropertyTableItem ; RESUTIL_PROPERTY_ITEM*
, "Ptr", pcbOutPropertyListSize ; DWORD* in/out
, "Ptr", pnPropertyCount ; DWORD* in/out
, "UInt") ; return: DWORD●ResUtilGetPropertySize(hkeyClusterKey, pPropertyTableItem, pcbOutPropertyListSize, pnPropertyCount) = DLL("RESUTILS.dll", "dword ResUtilGetPropertySize(void*, void*, void*, void*)")
# 呼び出し: ResUtilGetPropertySize(hkeyClusterKey, pPropertyTableItem, pcbOutPropertyListSize, pnPropertyCount)
# hkeyClusterKey : HKEY -> "void*"
# pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> "void*"
# pcbOutPropertyListSize : DWORD* in/out -> "void*"
# pnPropertyCount : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "resutils" fn ResUtilGetPropertySize(
hkeyClusterKey: ?*anyopaque, // HKEY
pPropertyTableItem: [*c]RESUTIL_PROPERTY_ITEM, // RESUTIL_PROPERTY_ITEM*
pcbOutPropertyListSize: [*c]u32, // DWORD* in/out
pnPropertyCount: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) u32;proc ResUtilGetPropertySize(
hkeyClusterKey: pointer, # HKEY
pPropertyTableItem: ptr RESUTIL_PROPERTY_ITEM, # RESUTIL_PROPERTY_ITEM*
pcbOutPropertyListSize: ptr uint32, # DWORD* in/out
pnPropertyCount: ptr uint32 # DWORD* in/out
): uint32 {.importc: "ResUtilGetPropertySize", stdcall, dynlib: "RESUTILS.dll".}pragma(lib, "resutils");
extern(Windows)
uint ResUtilGetPropertySize(
void* hkeyClusterKey, // HKEY
RESUTIL_PROPERTY_ITEM* pPropertyTableItem, // RESUTIL_PROPERTY_ITEM*
uint* pcbOutPropertyListSize, // DWORD* in/out
uint* pnPropertyCount // DWORD* in/out
);ccall((:ResUtilGetPropertySize, "RESUTILS.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Ptr{RESUTIL_PROPERTY_ITEM}, Ptr{UInt32}, Ptr{UInt32}),
hkeyClusterKey, pPropertyTableItem, pcbOutPropertyListSize, pnPropertyCount)
# hkeyClusterKey : HKEY -> Ptr{Cvoid}
# pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> Ptr{RESUTIL_PROPERTY_ITEM}
# pcbOutPropertyListSize : DWORD* in/out -> Ptr{UInt32}
# pnPropertyCount : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t ResUtilGetPropertySize(
void* hkeyClusterKey,
void* pPropertyTableItem,
uint32_t* pcbOutPropertyListSize,
uint32_t* pnPropertyCount);
]]
local resutils = ffi.load("resutils")
-- resutils.ResUtilGetPropertySize(hkeyClusterKey, pPropertyTableItem, pcbOutPropertyListSize, pnPropertyCount)
-- hkeyClusterKey : HKEY
-- pPropertyTableItem : RESUTIL_PROPERTY_ITEM*
-- pcbOutPropertyListSize : DWORD* in/out
-- pnPropertyCount : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('RESUTILS.dll');
const ResUtilGetPropertySize = lib.func('__stdcall', 'ResUtilGetPropertySize', 'uint32_t', ['void *', 'void *', 'uint32_t *', 'uint32_t *']);
// ResUtilGetPropertySize(hkeyClusterKey, pPropertyTableItem, pcbOutPropertyListSize, pnPropertyCount)
// hkeyClusterKey : HKEY -> 'void *'
// pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> 'void *'
// pcbOutPropertyListSize : DWORD* in/out -> 'uint32_t *'
// pnPropertyCount : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RESUTILS.dll", {
ResUtilGetPropertySize: { parameters: ["pointer", "pointer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.ResUtilGetPropertySize(hkeyClusterKey, pPropertyTableItem, pcbOutPropertyListSize, pnPropertyCount)
// hkeyClusterKey : HKEY -> "pointer"
// pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> "pointer"
// pcbOutPropertyListSize : DWORD* in/out -> "pointer"
// pnPropertyCount : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t ResUtilGetPropertySize(
void* hkeyClusterKey,
void* pPropertyTableItem,
uint32_t* pcbOutPropertyListSize,
uint32_t* pnPropertyCount);
C, "RESUTILS.dll");
// $ffi->ResUtilGetPropertySize(hkeyClusterKey, pPropertyTableItem, pcbOutPropertyListSize, pnPropertyCount);
// hkeyClusterKey : HKEY
// pPropertyTableItem : RESUTIL_PROPERTY_ITEM*
// pcbOutPropertyListSize : DWORD* in/out
// pnPropertyCount : 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 ResUtilGetPropertySize(
Pointer hkeyClusterKey, // HKEY
Pointer pPropertyTableItem, // RESUTIL_PROPERTY_ITEM*
IntByReference pcbOutPropertyListSize, // DWORD* in/out
IntByReference pnPropertyCount // DWORD* in/out
);
}@[Link("resutils")]
lib LibRESUTILS
fun ResUtilGetPropertySize = ResUtilGetPropertySize(
hkeyClusterKey : Void*, # HKEY
pPropertyTableItem : RESUTIL_PROPERTY_ITEM*, # RESUTIL_PROPERTY_ITEM*
pcbOutPropertyListSize : UInt32*, # DWORD* in/out
pnPropertyCount : 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 ResUtilGetPropertySizeNative = Uint32 Function(Pointer<Void>, Pointer<Void>, Pointer<Uint32>, Pointer<Uint32>);
typedef ResUtilGetPropertySizeDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Uint32>, Pointer<Uint32>);
final ResUtilGetPropertySize = DynamicLibrary.open('RESUTILS.dll')
.lookupFunction<ResUtilGetPropertySizeNative, ResUtilGetPropertySizeDart>('ResUtilGetPropertySize');
// hkeyClusterKey : HKEY -> Pointer<Void>
// pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> Pointer<Void>
// pcbOutPropertyListSize : DWORD* in/out -> Pointer<Uint32>
// pnPropertyCount : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ResUtilGetPropertySize(
hkeyClusterKey: THandle; // HKEY
pPropertyTableItem: Pointer; // RESUTIL_PROPERTY_ITEM*
pcbOutPropertyListSize: Pointer; // DWORD* in/out
pnPropertyCount: Pointer // DWORD* in/out
): DWORD; stdcall;
external 'RESUTILS.dll' name 'ResUtilGetPropertySize';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ResUtilGetPropertySize"
c_ResUtilGetPropertySize :: Ptr () -> Ptr () -> Ptr Word32 -> Ptr Word32 -> IO Word32
-- hkeyClusterKey : HKEY -> Ptr ()
-- pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> Ptr ()
-- pcbOutPropertyListSize : DWORD* in/out -> Ptr Word32
-- pnPropertyCount : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let resutilgetpropertysize =
foreign "ResUtilGetPropertySize"
((ptr void) @-> (ptr void) @-> (ptr uint32_t) @-> (ptr uint32_t) @-> returning uint32_t)
(* hkeyClusterKey : HKEY -> (ptr void) *)
(* pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> (ptr void) *)
(* pcbOutPropertyListSize : DWORD* in/out -> (ptr uint32_t) *)
(* pnPropertyCount : 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 ("ResUtilGetPropertySize" res-util-get-property-size :convention :stdcall) :uint32
(hkey-cluster-key :pointer) ; HKEY
(p-property-table-item :pointer) ; RESUTIL_PROPERTY_ITEM*
(pcb-out-property-list-size :pointer) ; DWORD* in/out
(pn-property-count :pointer)) ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ResUtilGetPropertySize = Win32::API::More->new('RESUTILS',
'DWORD ResUtilGetPropertySize(HANDLE hkeyClusterKey, LPVOID pPropertyTableItem, LPVOID pcbOutPropertyListSize, LPVOID pnPropertyCount)');
# my $ret = $ResUtilGetPropertySize->Call($hkeyClusterKey, $pPropertyTableItem, $pcbOutPropertyListSize, $pnPropertyCount);
# hkeyClusterKey : HKEY -> HANDLE
# pPropertyTableItem : RESUTIL_PROPERTY_ITEM* -> LPVOID
# pcbOutPropertyListSize : DWORD* in/out -> LPVOID
# pnPropertyCount : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。