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

ClusterRegEnumKey

関数
クラスターレジストリキーのサブキーを列挙する。
DLLCLUSAPI.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

INT ClusterRegEnumKey(
    HKEY hKey,
    DWORD dwIndex,
    LPWSTR lpszName,
    DWORD* lpcchName,
    FILETIME* lpftLastWriteTime   // optional
);

パラメーター

名前方向説明
hKeyHKEYinサブキーを列挙する対象の開いているクラスターレジストリキー。
dwIndexDWORDin列挙するサブキーの0始まりのインデックス。
lpszNameLPWSTRoutサブキー名を受け取るワイド文字列バッファ。
lpcchNameDWORD*inout入出力。バッファ文字数を渡し、必要文字数を受け取るDWORDポインタ。
lpftLastWriteTimeFILETIME*outoptionalサブキーの最終書き込み時刻を受け取るFILETIMEポインタ。NULL可。

戻り値の型: INT

各言語での呼び出し定義

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

INT ClusterRegEnumKey(
    HKEY hKey,
    DWORD dwIndex,
    LPWSTR lpszName,
    DWORD* lpcchName,
    FILETIME* lpftLastWriteTime   // optional
);
[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern int ClusterRegEnumKey(
    IntPtr hKey,   // HKEY
    uint dwIndex,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszName,   // LPWSTR out
    ref uint lpcchName,   // DWORD* in/out
    IntPtr lpftLastWriteTime   // FILETIME* optional, out
);
<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function ClusterRegEnumKey(
    hKey As IntPtr,   ' HKEY
    dwIndex As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> lpszName As System.Text.StringBuilder,   ' LPWSTR out
    ByRef lpcchName As UInteger,   ' DWORD* in/out
    lpftLastWriteTime As IntPtr   ' FILETIME* optional, out
) As Integer
End Function
' hKey : HKEY
' dwIndex : DWORD
' lpszName : LPWSTR out
' lpcchName : DWORD* in/out
' lpftLastWriteTime : FILETIME* optional, out
Declare PtrSafe Function ClusterRegEnumKey Lib "clusapi" ( _
    ByVal hKey As LongPtr, _
    ByVal dwIndex As Long, _
    ByVal lpszName As LongPtr, _
    ByRef lpcchName As Long, _
    ByVal lpftLastWriteTime As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ClusterRegEnumKey = ctypes.windll.clusapi.ClusterRegEnumKey
ClusterRegEnumKey.restype = ctypes.c_int
ClusterRegEnumKey.argtypes = [
    wintypes.HANDLE,  # hKey : HKEY
    wintypes.DWORD,  # dwIndex : DWORD
    wintypes.LPWSTR,  # lpszName : LPWSTR out
    ctypes.POINTER(wintypes.DWORD),  # lpcchName : DWORD* in/out
    ctypes.c_void_p,  # lpftLastWriteTime : FILETIME* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CLUSAPI.dll')
ClusterRegEnumKey = Fiddle::Function.new(
  lib['ClusterRegEnumKey'],
  [
    Fiddle::TYPE_VOIDP,  # hKey : HKEY
    -Fiddle::TYPE_INT,  # dwIndex : DWORD
    Fiddle::TYPE_VOIDP,  # lpszName : LPWSTR out
    Fiddle::TYPE_VOIDP,  # lpcchName : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # lpftLastWriteTime : FILETIME* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "clusapi")]
extern "system" {
    fn ClusterRegEnumKey(
        hKey: *mut core::ffi::c_void,  // HKEY
        dwIndex: u32,  // DWORD
        lpszName: *mut u16,  // LPWSTR out
        lpcchName: *mut u32,  // DWORD* in/out
        lpftLastWriteTime: *mut FILETIME  // FILETIME* optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern int ClusterRegEnumKey(IntPtr hKey, uint dwIndex, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszName, ref uint lpcchName, IntPtr lpftLastWriteTime);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_ClusterRegEnumKey' -Namespace Win32 -PassThru
# $api::ClusterRegEnumKey(hKey, dwIndex, lpszName, lpcchName, lpftLastWriteTime)
#uselib "CLUSAPI.dll"
#func global ClusterRegEnumKey "ClusterRegEnumKey" sptr, sptr, sptr, sptr, sptr
; ClusterRegEnumKey hKey, dwIndex, varptr(lpszName), varptr(lpcchName), varptr(lpftLastWriteTime)   ; 戻り値は stat
; hKey : HKEY -> "sptr"
; dwIndex : DWORD -> "sptr"
; lpszName : LPWSTR out -> "sptr"
; lpcchName : DWORD* in/out -> "sptr"
; lpftLastWriteTime : FILETIME* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "CLUSAPI.dll"
#cfunc global ClusterRegEnumKey "ClusterRegEnumKey" sptr, int, var, var, var
; res = ClusterRegEnumKey(hKey, dwIndex, lpszName, lpcchName, lpftLastWriteTime)
; hKey : HKEY -> "sptr"
; dwIndex : DWORD -> "int"
; lpszName : LPWSTR out -> "var"
; lpcchName : DWORD* in/out -> "var"
; lpftLastWriteTime : FILETIME* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT ClusterRegEnumKey(HKEY hKey, DWORD dwIndex, LPWSTR lpszName, DWORD* lpcchName, FILETIME* lpftLastWriteTime)
#uselib "CLUSAPI.dll"
#cfunc global ClusterRegEnumKey "ClusterRegEnumKey" intptr, int, var, var, var
; res = ClusterRegEnumKey(hKey, dwIndex, lpszName, lpcchName, lpftLastWriteTime)
; hKey : HKEY -> "intptr"
; dwIndex : DWORD -> "int"
; lpszName : LPWSTR out -> "var"
; lpcchName : DWORD* in/out -> "var"
; lpftLastWriteTime : FILETIME* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procClusterRegEnumKey = clusapi.NewProc("ClusterRegEnumKey")
)

// hKey (HKEY), dwIndex (DWORD), lpszName (LPWSTR out), lpcchName (DWORD* in/out), lpftLastWriteTime (FILETIME* optional, out)
r1, _, err := procClusterRegEnumKey.Call(
	uintptr(hKey),
	uintptr(dwIndex),
	uintptr(lpszName),
	uintptr(lpcchName),
	uintptr(lpftLastWriteTime),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function ClusterRegEnumKey(
  hKey: THandle;   // HKEY
  dwIndex: DWORD;   // DWORD
  lpszName: PWideChar;   // LPWSTR out
  lpcchName: Pointer;   // DWORD* in/out
  lpftLastWriteTime: Pointer   // FILETIME* optional, out
): Integer; stdcall;
  external 'CLUSAPI.dll' name 'ClusterRegEnumKey';
result := DllCall("CLUSAPI\ClusterRegEnumKey"
    , "Ptr", hKey   ; HKEY
    , "UInt", dwIndex   ; DWORD
    , "Ptr", lpszName   ; LPWSTR out
    , "Ptr", lpcchName   ; DWORD* in/out
    , "Ptr", lpftLastWriteTime   ; FILETIME* optional, out
    , "Int")   ; return: INT
●ClusterRegEnumKey(hKey, dwIndex, lpszName, lpcchName, lpftLastWriteTime) = DLL("CLUSAPI.dll", "int ClusterRegEnumKey(void*, dword, char*, void*, void*)")
# 呼び出し: ClusterRegEnumKey(hKey, dwIndex, lpszName, lpcchName, lpftLastWriteTime)
# hKey : HKEY -> "void*"
# dwIndex : DWORD -> "dword"
# lpszName : LPWSTR out -> "char*"
# lpcchName : DWORD* in/out -> "void*"
# lpftLastWriteTime : FILETIME* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef ClusterRegEnumKeyNative = Int32 Function(Pointer<Void>, Uint32, Pointer<Utf16>, Pointer<Uint32>, Pointer<Void>);
typedef ClusterRegEnumKeyDart = int Function(Pointer<Void>, int, Pointer<Utf16>, Pointer<Uint32>, Pointer<Void>);
final ClusterRegEnumKey = DynamicLibrary.open('CLUSAPI.dll')
    .lookupFunction<ClusterRegEnumKeyNative, ClusterRegEnumKeyDart>('ClusterRegEnumKey');
// hKey : HKEY -> Pointer<Void>
// dwIndex : DWORD -> Uint32
// lpszName : LPWSTR out -> Pointer<Utf16>
// lpcchName : DWORD* in/out -> Pointer<Uint32>
// lpftLastWriteTime : FILETIME* optional, out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ClusterRegEnumKey(
  hKey: THandle;   // HKEY
  dwIndex: DWORD;   // DWORD
  lpszName: PWideChar;   // LPWSTR out
  lpcchName: Pointer;   // DWORD* in/out
  lpftLastWriteTime: Pointer   // FILETIME* optional, out
): Integer; stdcall;
  external 'CLUSAPI.dll' name 'ClusterRegEnumKey';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ClusterRegEnumKey"
  c_ClusterRegEnumKey :: Ptr () -> Word32 -> CWString -> Ptr Word32 -> Ptr () -> IO Int32
-- hKey : HKEY -> Ptr ()
-- dwIndex : DWORD -> Word32
-- lpszName : LPWSTR out -> CWString
-- lpcchName : DWORD* in/out -> Ptr Word32
-- lpftLastWriteTime : FILETIME* optional, out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let clusterregenumkey =
  foreign "ClusterRegEnumKey"
    ((ptr void) @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint32_t) @-> (ptr void) @-> returning int32_t)
(* hKey : HKEY -> (ptr void) *)
(* dwIndex : DWORD -> uint32_t *)
(* lpszName : LPWSTR out -> (ptr uint16_t) *)
(* lpcchName : DWORD* in/out -> (ptr uint32_t) *)
(* lpftLastWriteTime : FILETIME* optional, out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library clusapi (t "CLUSAPI.dll"))
(cffi:use-foreign-library clusapi)

(cffi:defcfun ("ClusterRegEnumKey" cluster-reg-enum-key :convention :stdcall) :int32
  (h-key :pointer)   ; HKEY
  (dw-index :uint32)   ; DWORD
  (lpsz-name :pointer)   ; LPWSTR out
  (lpcch-name :pointer)   ; DWORD* in/out
  (lpft-last-write-time :pointer))   ; FILETIME* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ClusterRegEnumKey = Win32::API::More->new('CLUSAPI',
    'int ClusterRegEnumKey(HANDLE hKey, DWORD dwIndex, LPWSTR lpszName, LPVOID lpcchName, LPVOID lpftLastWriteTime)');
# my $ret = $ClusterRegEnumKey->Call($hKey, $dwIndex, $lpszName, $lpcchName, $lpftLastWriteTime);
# hKey : HKEY -> HANDLE
# dwIndex : DWORD -> DWORD
# lpszName : LPWSTR out -> LPWSTR
# lpcchName : DWORD* in/out -> LPVOID
# lpftLastWriteTime : FILETIME* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型