Win32 API 日本語リファレンス
ホームUI.Shell › SHCreatePropSheetExtArray

SHCreatePropSheetExtArray

関数
レジストリからプロパティシート拡張配列を生成する。
DLLSHELL32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HPSXA SHCreatePropSheetExtArray(
    HKEY hKey,
    LPCWSTR pszSubKey,   // optional
    DWORD max_iface
);

パラメーター

名前方向説明
hKeyHKEYinプロパティシート拡張ハンドラーを含むサブキーが格納されているレジストリのルートキー。たとえば HKEY_LOCAL_MACHINE です。
pszSubKeyLPCWSTRinoptional

shellex\PropertySheetHandlers を含むサブキーの名前を指定する、null で終わる文字列へのポインター。

たとえば、hkeyHKEY_LOCAL_MACHINE を指定し、pszSubkey に "Software\Microsoft\Windows\CurrentVersion\Controls Folder\Display" を指定した場合、この関数は次のサブキーを使用してプロパティシート拡張ハンドラーを返します。

HKEY_LOCAL_MACHINE
   SOFTWARE
      Microsoft
         Windows
            CurrentVersion
               Controls Folder
                  Display
                     shellex
                        PropertySheetHandlers
max_ifaceDWORDin返されるプロパティシートハンドラーの最大数。

戻り値の型: HPSXA

公式ドキュメント

SHCreatePropSheetExtArray は変更されるか、利用できなくなる可能性があります。

戻り値

型: HPSXA

プロパティシートハンドラーの配列へのハンドルを返します。この値を SHAddFromPropSheetExtArray に渡してください。この値に直接アクセスすることはありません。

解説(Remarks)

返された HPSXA ハンドルの使用を終えたら、SHDestroyPropSheetExtArray を呼び出して破棄してください。

この関数は、最大で max_iface 個のプロパティシート拡張を配列に読み込み、その配列を SHAddFromPropSheetExtArray に渡します。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

HPSXA SHCreatePropSheetExtArray(
    HKEY hKey,
    LPCWSTR pszSubKey,   // optional
    DWORD max_iface
);
[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern IntPtr SHCreatePropSheetExtArray(
    IntPtr hKey,   // HKEY
    [MarshalAs(UnmanagedType.LPWStr)] string pszSubKey,   // LPCWSTR optional
    uint max_iface   // DWORD
);
<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function SHCreatePropSheetExtArray(
    hKey As IntPtr,   ' HKEY
    <MarshalAs(UnmanagedType.LPWStr)> pszSubKey As String,   ' LPCWSTR optional
    max_iface As UInteger   ' DWORD
) As IntPtr
End Function
' hKey : HKEY
' pszSubKey : LPCWSTR optional
' max_iface : DWORD
Declare PtrSafe Function SHCreatePropSheetExtArray Lib "shell32" ( _
    ByVal hKey As LongPtr, _
    ByVal pszSubKey As LongPtr, _
    ByVal max_iface As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SHCreatePropSheetExtArray = ctypes.windll.shell32.SHCreatePropSheetExtArray
SHCreatePropSheetExtArray.restype = ctypes.c_void_p
SHCreatePropSheetExtArray.argtypes = [
    wintypes.HANDLE,  # hKey : HKEY
    wintypes.LPCWSTR,  # pszSubKey : LPCWSTR optional
    wintypes.DWORD,  # max_iface : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHELL32.dll')
SHCreatePropSheetExtArray = Fiddle::Function.new(
  lib['SHCreatePropSheetExtArray'],
  [
    Fiddle::TYPE_VOIDP,  # hKey : HKEY
    Fiddle::TYPE_VOIDP,  # pszSubKey : LPCWSTR optional
    -Fiddle::TYPE_INT,  # max_iface : DWORD
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "shell32")]
extern "system" {
    fn SHCreatePropSheetExtArray(
        hKey: *mut core::ffi::c_void,  // HKEY
        pszSubKey: *const u16,  // LPCWSTR optional
        max_iface: u32  // DWORD
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHELL32.dll")]
public static extern IntPtr SHCreatePropSheetExtArray(IntPtr hKey, [MarshalAs(UnmanagedType.LPWStr)] string pszSubKey, uint max_iface);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHCreatePropSheetExtArray' -Namespace Win32 -PassThru
# $api::SHCreatePropSheetExtArray(hKey, pszSubKey, max_iface)
#uselib "SHELL32.dll"
#func global SHCreatePropSheetExtArray "SHCreatePropSheetExtArray" sptr, sptr, sptr
; SHCreatePropSheetExtArray hKey, pszSubKey, max_iface   ; 戻り値は stat
; hKey : HKEY -> "sptr"
; pszSubKey : LPCWSTR optional -> "sptr"
; max_iface : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHELL32.dll"
#cfunc global SHCreatePropSheetExtArray "SHCreatePropSheetExtArray" sptr, wstr, int
; res = SHCreatePropSheetExtArray(hKey, pszSubKey, max_iface)
; hKey : HKEY -> "sptr"
; pszSubKey : LPCWSTR optional -> "wstr"
; max_iface : DWORD -> "int"
; HPSXA SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, DWORD max_iface)
#uselib "SHELL32.dll"
#cfunc global SHCreatePropSheetExtArray "SHCreatePropSheetExtArray" intptr, wstr, int
; res = SHCreatePropSheetExtArray(hKey, pszSubKey, max_iface)
; hKey : HKEY -> "intptr"
; pszSubKey : LPCWSTR optional -> "wstr"
; max_iface : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shell32 = windows.NewLazySystemDLL("SHELL32.dll")
	procSHCreatePropSheetExtArray = shell32.NewProc("SHCreatePropSheetExtArray")
)

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

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

typedef SHCreatePropSheetExtArrayNative = Pointer<Void> Function(Pointer<Void>, Pointer<Utf16>, Uint32);
typedef SHCreatePropSheetExtArrayDart = Pointer<Void> Function(Pointer<Void>, Pointer<Utf16>, int);
final SHCreatePropSheetExtArray = DynamicLibrary.open('SHELL32.dll')
    .lookupFunction<SHCreatePropSheetExtArrayNative, SHCreatePropSheetExtArrayDart>('SHCreatePropSheetExtArray');
// hKey : HKEY -> Pointer<Void>
// pszSubKey : LPCWSTR optional -> Pointer<Utf16>
// max_iface : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SHCreatePropSheetExtArray(
  hKey: THandle;   // HKEY
  pszSubKey: PWideChar;   // LPCWSTR optional
  max_iface: DWORD   // DWORD
): THandle; stdcall;
  external 'SHELL32.dll' name 'SHCreatePropSheetExtArray';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SHCreatePropSheetExtArray"
  c_SHCreatePropSheetExtArray :: Ptr () -> CWString -> Word32 -> IO (Ptr ())
-- hKey : HKEY -> Ptr ()
-- pszSubKey : LPCWSTR optional -> CWString
-- max_iface : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let shcreatepropsheetextarray =
  foreign "SHCreatePropSheetExtArray"
    ((ptr void) @-> (ptr uint16_t) @-> uint32_t @-> returning (ptr void))
(* hKey : HKEY -> (ptr void) *)
(* pszSubKey : LPCWSTR optional -> (ptr uint16_t) *)
(* max_iface : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library shell32 (t "SHELL32.dll"))
(cffi:use-foreign-library shell32)

(cffi:defcfun ("SHCreatePropSheetExtArray" shcreate-prop-sheet-ext-array :convention :stdcall) :pointer
  (h-key :pointer)   ; HKEY
  (psz-sub-key (:string :encoding :utf-16le))   ; LPCWSTR optional
  (max-iface :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SHCreatePropSheetExtArray = Win32::API::More->new('SHELL32',
    'HANDLE SHCreatePropSheetExtArray(HANDLE hKey, LPCWSTR pszSubKey, DWORD max_iface)');
# my $ret = $SHCreatePropSheetExtArray->Call($hKey, $pszSubKey, $max_iface);
# hKey : HKEY -> HANDLE
# pszSubKey : LPCWSTR optional -> LPCWSTR
# max_iface : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。