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

SHRegEnumUSValueA

関数
ユーザー単位レジストリキー内の値を列挙する。
DLLSHLWAPI.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// SHLWAPI.dll  (ANSI / -A)
#include <windows.h>

WIN32_ERROR SHRegEnumUSValueA(
    INT_PTR hUSkey,
    DWORD dwIndex,
    LPSTR pszValueName,
    DWORD* pcchValueName,
    DWORD* pdwType,   // optional
    void* pvData,   // optional
    DWORD* pcbData,   // optional
    SHREGENUM_FLAGS enumRegFlags
);

パラメーター

名前方向
hUSkeyINT_PTRin
dwIndexDWORDin
pszValueNameLPSTRout
pcchValueNameDWORD*inout
pdwTypeDWORD*outoptional
pvDatavoid*outoptional
pcbDataDWORD*inoutoptional
enumRegFlagsSHREGENUM_FLAGSin

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

// SHLWAPI.dll  (ANSI / -A)
#include <windows.h>

WIN32_ERROR SHRegEnumUSValueA(
    INT_PTR hUSkey,
    DWORD dwIndex,
    LPSTR pszValueName,
    DWORD* pcchValueName,
    DWORD* pdwType,   // optional
    void* pvData,   // optional
    DWORD* pcbData,   // optional
    SHREGENUM_FLAGS enumRegFlags
);
[DllImport("SHLWAPI.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint SHRegEnumUSValueA(
    IntPtr hUSkey,   // INT_PTR
    uint dwIndex,   // DWORD
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszValueName,   // LPSTR out
    ref uint pcchValueName,   // DWORD* in/out
    IntPtr pdwType,   // DWORD* optional, out
    IntPtr pvData,   // void* optional, out
    IntPtr pcbData,   // DWORD* optional, in/out
    int enumRegFlags   // SHREGENUM_FLAGS
);
<DllImport("SHLWAPI.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SHRegEnumUSValueA(
    hUSkey As IntPtr,   ' INT_PTR
    dwIndex As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPStr)> pszValueName As System.Text.StringBuilder,   ' LPSTR out
    ByRef pcchValueName As UInteger,   ' DWORD* in/out
    pdwType As IntPtr,   ' DWORD* optional, out
    pvData As IntPtr,   ' void* optional, out
    pcbData As IntPtr,   ' DWORD* optional, in/out
    enumRegFlags As Integer   ' SHREGENUM_FLAGS
) As UInteger
End Function
' hUSkey : INT_PTR
' dwIndex : DWORD
' pszValueName : LPSTR out
' pcchValueName : DWORD* in/out
' pdwType : DWORD* optional, out
' pvData : void* optional, out
' pcbData : DWORD* optional, in/out
' enumRegFlags : SHREGENUM_FLAGS
Declare PtrSafe Function SHRegEnumUSValueA Lib "shlwapi" ( _
    ByVal hUSkey As LongPtr, _
    ByVal dwIndex As Long, _
    ByVal pszValueName As String, _
    ByRef pcchValueName As Long, _
    ByVal pdwType As LongPtr, _
    ByVal pvData As LongPtr, _
    ByVal pcbData As LongPtr, _
    ByVal enumRegFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SHRegEnumUSValueA = ctypes.windll.shlwapi.SHRegEnumUSValueA
SHRegEnumUSValueA.restype = wintypes.DWORD
SHRegEnumUSValueA.argtypes = [
    ctypes.c_ssize_t,  # hUSkey : INT_PTR
    wintypes.DWORD,  # dwIndex : DWORD
    wintypes.LPSTR,  # pszValueName : LPSTR out
    ctypes.POINTER(wintypes.DWORD),  # pcchValueName : DWORD* in/out
    ctypes.POINTER(wintypes.DWORD),  # pdwType : DWORD* optional, out
    ctypes.POINTER(None),  # pvData : void* optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcbData : DWORD* optional, in/out
    ctypes.c_int,  # enumRegFlags : SHREGENUM_FLAGS
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHLWAPI.dll')
SHRegEnumUSValueA = Fiddle::Function.new(
  lib['SHRegEnumUSValueA'],
  [
    Fiddle::TYPE_INTPTR_T,  # hUSkey : INT_PTR
    -Fiddle::TYPE_INT,  # dwIndex : DWORD
    Fiddle::TYPE_VOIDP,  # pszValueName : LPSTR out
    Fiddle::TYPE_VOIDP,  # pcchValueName : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # pdwType : DWORD* optional, out
    Fiddle::TYPE_VOIDP,  # pvData : void* optional, out
    Fiddle::TYPE_VOIDP,  # pcbData : DWORD* optional, in/out
    Fiddle::TYPE_INT,  # enumRegFlags : SHREGENUM_FLAGS
  ],
  -Fiddle::TYPE_INT)
#[link(name = "shlwapi")]
extern "system" {
    fn SHRegEnumUSValueA(
        hUSkey: isize,  // INT_PTR
        dwIndex: u32,  // DWORD
        pszValueName: *mut u8,  // LPSTR out
        pcchValueName: *mut u32,  // DWORD* in/out
        pdwType: *mut u32,  // DWORD* optional, out
        pvData: *mut (),  // void* optional, out
        pcbData: *mut u32,  // DWORD* optional, in/out
        enumRegFlags: i32  // SHREGENUM_FLAGS
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHLWAPI.dll", CharSet = CharSet.Ansi)]
public static extern uint SHRegEnumUSValueA(IntPtr hUSkey, uint dwIndex, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszValueName, ref uint pcchValueName, IntPtr pdwType, IntPtr pvData, IntPtr pcbData, int enumRegFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_SHRegEnumUSValueA' -Namespace Win32 -PassThru
# $api::SHRegEnumUSValueA(hUSkey, dwIndex, pszValueName, pcchValueName, pdwType, pvData, pcbData, enumRegFlags)
#uselib "SHLWAPI.dll"
#func global SHRegEnumUSValueA "SHRegEnumUSValueA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SHRegEnumUSValueA hUSkey, dwIndex, varptr(pszValueName), varptr(pcchValueName), varptr(pdwType), pvData, varptr(pcbData), enumRegFlags   ; 戻り値は stat
; hUSkey : INT_PTR -> "sptr"
; dwIndex : DWORD -> "sptr"
; pszValueName : LPSTR out -> "sptr"
; pcchValueName : DWORD* in/out -> "sptr"
; pdwType : DWORD* optional, out -> "sptr"
; pvData : void* optional, out -> "sptr"
; pcbData : DWORD* optional, in/out -> "sptr"
; enumRegFlags : SHREGENUM_FLAGS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SHLWAPI.dll"
#cfunc global SHRegEnumUSValueA "SHRegEnumUSValueA" sptr, int, var, var, var, sptr, var, int
; res = SHRegEnumUSValueA(hUSkey, dwIndex, pszValueName, pcchValueName, pdwType, pvData, pcbData, enumRegFlags)
; hUSkey : INT_PTR -> "sptr"
; dwIndex : DWORD -> "int"
; pszValueName : LPSTR out -> "var"
; pcchValueName : DWORD* in/out -> "var"
; pdwType : DWORD* optional, out -> "var"
; pvData : void* optional, out -> "sptr"
; pcbData : DWORD* optional, in/out -> "var"
; enumRegFlags : SHREGENUM_FLAGS -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; WIN32_ERROR SHRegEnumUSValueA(INT_PTR hUSkey, DWORD dwIndex, LPSTR pszValueName, DWORD* pcchValueName, DWORD* pdwType, void* pvData, DWORD* pcbData, SHREGENUM_FLAGS enumRegFlags)
#uselib "SHLWAPI.dll"
#cfunc global SHRegEnumUSValueA "SHRegEnumUSValueA" intptr, int, var, var, var, intptr, var, int
; res = SHRegEnumUSValueA(hUSkey, dwIndex, pszValueName, pcchValueName, pdwType, pvData, pcbData, enumRegFlags)
; hUSkey : INT_PTR -> "intptr"
; dwIndex : DWORD -> "int"
; pszValueName : LPSTR out -> "var"
; pcchValueName : DWORD* in/out -> "var"
; pdwType : DWORD* optional, out -> "var"
; pvData : void* optional, out -> "intptr"
; pcbData : DWORD* optional, in/out -> "var"
; enumRegFlags : SHREGENUM_FLAGS -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procSHRegEnumUSValueA = shlwapi.NewProc("SHRegEnumUSValueA")
)

// hUSkey (INT_PTR), dwIndex (DWORD), pszValueName (LPSTR out), pcchValueName (DWORD* in/out), pdwType (DWORD* optional, out), pvData (void* optional, out), pcbData (DWORD* optional, in/out), enumRegFlags (SHREGENUM_FLAGS)
r1, _, err := procSHRegEnumUSValueA.Call(
	uintptr(hUSkey),
	uintptr(dwIndex),
	uintptr(pszValueName),
	uintptr(pcchValueName),
	uintptr(pdwType),
	uintptr(pvData),
	uintptr(pcbData),
	uintptr(enumRegFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WIN32_ERROR
function SHRegEnumUSValueA(
  hUSkey: NativeInt;   // INT_PTR
  dwIndex: DWORD;   // DWORD
  pszValueName: PAnsiChar;   // LPSTR out
  pcchValueName: Pointer;   // DWORD* in/out
  pdwType: Pointer;   // DWORD* optional, out
  pvData: Pointer;   // void* optional, out
  pcbData: Pointer;   // DWORD* optional, in/out
  enumRegFlags: Integer   // SHREGENUM_FLAGS
): DWORD; stdcall;
  external 'SHLWAPI.dll' name 'SHRegEnumUSValueA';
result := DllCall("SHLWAPI\SHRegEnumUSValueA"
    , "Ptr", hUSkey   ; INT_PTR
    , "UInt", dwIndex   ; DWORD
    , "Ptr", pszValueName   ; LPSTR out
    , "Ptr", pcchValueName   ; DWORD* in/out
    , "Ptr", pdwType   ; DWORD* optional, out
    , "Ptr", pvData   ; void* optional, out
    , "Ptr", pcbData   ; DWORD* optional, in/out
    , "Int", enumRegFlags   ; SHREGENUM_FLAGS
    , "UInt")   ; return: WIN32_ERROR
●SHRegEnumUSValueA(hUSkey, dwIndex, pszValueName, pcchValueName, pdwType, pvData, pcbData, enumRegFlags) = DLL("SHLWAPI.dll", "dword SHRegEnumUSValueA(int, dword, char*, void*, void*, void*, void*, int)")
# 呼び出し: SHRegEnumUSValueA(hUSkey, dwIndex, pszValueName, pcchValueName, pdwType, pvData, pcbData, enumRegFlags)
# hUSkey : INT_PTR -> "int"
# dwIndex : DWORD -> "dword"
# pszValueName : LPSTR out -> "char*"
# pcchValueName : DWORD* in/out -> "void*"
# pdwType : DWORD* optional, out -> "void*"
# pvData : void* optional, out -> "void*"
# pcbData : DWORD* optional, in/out -> "void*"
# enumRegFlags : SHREGENUM_FLAGS -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。