SHRegEnumUSValueW
関数ユーザー単位レジストリキー内の値を列挙する。
シグネチャ
// SHLWAPI.dll (Unicode / -W)
#include <windows.h>
WIN32_ERROR SHRegEnumUSValueW(
INT_PTR hUSkey,
DWORD dwIndex,
LPWSTR pszValueName,
DWORD* pcchValueName,
DWORD* pdwType, // optional
void* pvData, // optional
DWORD* pcbData, // optional
SHREGENUM_FLAGS enumRegFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hUSkey | INT_PTR | in |
| dwIndex | DWORD | in |
| pszValueName | LPWSTR | out |
| pcchValueName | DWORD* | inout |
| pdwType | DWORD* | outoptional |
| pvData | void* | outoptional |
| pcbData | DWORD* | inoutoptional |
| enumRegFlags | SHREGENUM_FLAGS | in |
戻り値の型: WIN32_ERROR
各言語での呼び出し定義
// SHLWAPI.dll (Unicode / -W)
#include <windows.h>
WIN32_ERROR SHRegEnumUSValueW(
INT_PTR hUSkey,
DWORD dwIndex,
LPWSTR pszValueName,
DWORD* pcchValueName,
DWORD* pdwType, // optional
void* pvData, // optional
DWORD* pcbData, // optional
SHREGENUM_FLAGS enumRegFlags
);[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint SHRegEnumUSValueW(
IntPtr hUSkey, // INT_PTR
uint dwIndex, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszValueName, // LPWSTR 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.Unicode, ExactSpelling:=True)>
Public Shared Function SHRegEnumUSValueW(
hUSkey As IntPtr, ' INT_PTR
dwIndex As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> pszValueName As System.Text.StringBuilder, ' LPWSTR 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 : LPWSTR out
' pcchValueName : DWORD* in/out
' pdwType : DWORD* optional, out
' pvData : void* optional, out
' pcbData : DWORD* optional, in/out
' enumRegFlags : SHREGENUM_FLAGS
Declare PtrSafe Function SHRegEnumUSValueW Lib "shlwapi" ( _
ByVal hUSkey As LongPtr, _
ByVal dwIndex As Long, _
ByVal pszValueName As LongPtr, _
ByRef pcchValueName As Long, _
ByVal pdwType As LongPtr, _
ByVal pvData As LongPtr, _
ByVal pcbData As LongPtr, _
ByVal enumRegFlags As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SHRegEnumUSValueW = ctypes.windll.shlwapi.SHRegEnumUSValueW
SHRegEnumUSValueW.restype = wintypes.DWORD
SHRegEnumUSValueW.argtypes = [
ctypes.c_ssize_t, # hUSkey : INT_PTR
wintypes.DWORD, # dwIndex : DWORD
wintypes.LPWSTR, # pszValueName : LPWSTR 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')
SHRegEnumUSValueW = Fiddle::Function.new(
lib['SHRegEnumUSValueW'],
[
Fiddle::TYPE_INTPTR_T, # hUSkey : INT_PTR
-Fiddle::TYPE_INT, # dwIndex : DWORD
Fiddle::TYPE_VOIDP, # pszValueName : LPWSTR 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)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "shlwapi")]
extern "system" {
fn SHRegEnumUSValueW(
hUSkey: isize, // INT_PTR
dwIndex: u32, // DWORD
pszValueName: *mut u16, // LPWSTR 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.Unicode)]
public static extern uint SHRegEnumUSValueW(IntPtr hUSkey, uint dwIndex, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszValueName, ref uint pcchValueName, IntPtr pdwType, IntPtr pvData, IntPtr pcbData, int enumRegFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_SHRegEnumUSValueW' -Namespace Win32 -PassThru
# $api::SHRegEnumUSValueW(hUSkey, dwIndex, pszValueName, pcchValueName, pdwType, pvData, pcbData, enumRegFlags)#uselib "SHLWAPI.dll"
#func global SHRegEnumUSValueW "SHRegEnumUSValueW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; SHRegEnumUSValueW hUSkey, dwIndex, varptr(pszValueName), varptr(pcchValueName), varptr(pdwType), pvData, varptr(pcbData), enumRegFlags ; 戻り値は stat
; hUSkey : INT_PTR -> "wptr"
; dwIndex : DWORD -> "wptr"
; pszValueName : LPWSTR out -> "wptr"
; pcchValueName : DWORD* in/out -> "wptr"
; pdwType : DWORD* optional, out -> "wptr"
; pvData : void* optional, out -> "wptr"
; pcbData : DWORD* optional, in/out -> "wptr"
; enumRegFlags : SHREGENUM_FLAGS -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHLWAPI.dll" #cfunc global SHRegEnumUSValueW "SHRegEnumUSValueW" sptr, int, var, var, var, sptr, var, int ; res = SHRegEnumUSValueW(hUSkey, dwIndex, pszValueName, pcchValueName, pdwType, pvData, pcbData, enumRegFlags) ; hUSkey : INT_PTR -> "sptr" ; dwIndex : DWORD -> "int" ; pszValueName : LPWSTR 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 方式にも切替可。#uselib "SHLWAPI.dll" #cfunc global SHRegEnumUSValueW "SHRegEnumUSValueW" sptr, int, sptr, sptr, sptr, sptr, sptr, int ; res = SHRegEnumUSValueW(hUSkey, dwIndex, varptr(pszValueName), varptr(pcchValueName), varptr(pdwType), pvData, varptr(pcbData), enumRegFlags) ; hUSkey : INT_PTR -> "sptr" ; dwIndex : DWORD -> "int" ; pszValueName : LPWSTR 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 -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; WIN32_ERROR SHRegEnumUSValueW(INT_PTR hUSkey, DWORD dwIndex, LPWSTR pszValueName, DWORD* pcchValueName, DWORD* pdwType, void* pvData, DWORD* pcbData, SHREGENUM_FLAGS enumRegFlags) #uselib "SHLWAPI.dll" #cfunc global SHRegEnumUSValueW "SHRegEnumUSValueW" intptr, int, var, var, var, intptr, var, int ; res = SHRegEnumUSValueW(hUSkey, dwIndex, pszValueName, pcchValueName, pdwType, pvData, pcbData, enumRegFlags) ; hUSkey : INT_PTR -> "intptr" ; dwIndex : DWORD -> "int" ; pszValueName : LPWSTR 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 方式にも切替可。; WIN32_ERROR SHRegEnumUSValueW(INT_PTR hUSkey, DWORD dwIndex, LPWSTR pszValueName, DWORD* pcchValueName, DWORD* pdwType, void* pvData, DWORD* pcbData, SHREGENUM_FLAGS enumRegFlags) #uselib "SHLWAPI.dll" #cfunc global SHRegEnumUSValueW "SHRegEnumUSValueW" intptr, int, intptr, intptr, intptr, intptr, intptr, int ; res = SHRegEnumUSValueW(hUSkey, dwIndex, varptr(pszValueName), varptr(pcchValueName), varptr(pdwType), pvData, varptr(pcbData), enumRegFlags) ; hUSkey : INT_PTR -> "intptr" ; dwIndex : DWORD -> "int" ; pszValueName : LPWSTR out -> "intptr" ; pcchValueName : DWORD* in/out -> "intptr" ; pdwType : DWORD* optional, out -> "intptr" ; pvData : void* optional, out -> "intptr" ; pcbData : DWORD* optional, in/out -> "intptr" ; enumRegFlags : SHREGENUM_FLAGS -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procSHRegEnumUSValueW = shlwapi.NewProc("SHRegEnumUSValueW")
)
// hUSkey (INT_PTR), dwIndex (DWORD), pszValueName (LPWSTR out), pcchValueName (DWORD* in/out), pdwType (DWORD* optional, out), pvData (void* optional, out), pcbData (DWORD* optional, in/out), enumRegFlags (SHREGENUM_FLAGS)
r1, _, err := procSHRegEnumUSValueW.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_ERRORfunction SHRegEnumUSValueW(
hUSkey: NativeInt; // INT_PTR
dwIndex: DWORD; // DWORD
pszValueName: PWideChar; // LPWSTR 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 'SHRegEnumUSValueW';result := DllCall("SHLWAPI\SHRegEnumUSValueW"
, "Ptr", hUSkey ; INT_PTR
, "UInt", dwIndex ; DWORD
, "Ptr", pszValueName ; LPWSTR 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●SHRegEnumUSValueW(hUSkey, dwIndex, pszValueName, pcchValueName, pdwType, pvData, pcbData, enumRegFlags) = DLL("SHLWAPI.dll", "dword SHRegEnumUSValueW(int, dword, char*, void*, void*, void*, void*, int)")
# 呼び出し: SHRegEnumUSValueW(hUSkey, dwIndex, pszValueName, pcchValueName, pdwType, pvData, pcbData, enumRegFlags)
# hUSkey : INT_PTR -> "int"
# dwIndex : DWORD -> "dword"
# pszValueName : LPWSTR 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)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。