SHRegEnumUSKeyA
関数ユーザー単位レジストリキーのサブキーを列挙する。
シグネチャ
// SHLWAPI.dll (ANSI / -A)
#include <windows.h>
WIN32_ERROR SHRegEnumUSKeyA(
INT_PTR hUSKey,
DWORD dwIndex,
LPSTR pszName,
DWORD* pcchName,
SHREGENUM_FLAGS enumRegFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hUSKey | INT_PTR | in |
| dwIndex | DWORD | in |
| pszName | LPSTR | out |
| pcchName | DWORD* | inout |
| enumRegFlags | SHREGENUM_FLAGS | in |
戻り値の型: WIN32_ERROR
各言語での呼び出し定義
// SHLWAPI.dll (ANSI / -A)
#include <windows.h>
WIN32_ERROR SHRegEnumUSKeyA(
INT_PTR hUSKey,
DWORD dwIndex,
LPSTR pszName,
DWORD* pcchName,
SHREGENUM_FLAGS enumRegFlags
);[DllImport("SHLWAPI.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint SHRegEnumUSKeyA(
IntPtr hUSKey, // INT_PTR
uint dwIndex, // DWORD
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszName, // LPSTR out
ref uint pcchName, // DWORD* in/out
int enumRegFlags // SHREGENUM_FLAGS
);<DllImport("SHLWAPI.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SHRegEnumUSKeyA(
hUSKey As IntPtr, ' INT_PTR
dwIndex As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> pszName As System.Text.StringBuilder, ' LPSTR out
ByRef pcchName As UInteger, ' DWORD* in/out
enumRegFlags As Integer ' SHREGENUM_FLAGS
) As UInteger
End Function' hUSKey : INT_PTR
' dwIndex : DWORD
' pszName : LPSTR out
' pcchName : DWORD* in/out
' enumRegFlags : SHREGENUM_FLAGS
Declare PtrSafe Function SHRegEnumUSKeyA Lib "shlwapi" ( _
ByVal hUSKey As LongPtr, _
ByVal dwIndex As Long, _
ByVal pszName As String, _
ByRef pcchName As Long, _
ByVal enumRegFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SHRegEnumUSKeyA = ctypes.windll.shlwapi.SHRegEnumUSKeyA
SHRegEnumUSKeyA.restype = wintypes.DWORD
SHRegEnumUSKeyA.argtypes = [
ctypes.c_ssize_t, # hUSKey : INT_PTR
wintypes.DWORD, # dwIndex : DWORD
wintypes.LPSTR, # pszName : LPSTR out
ctypes.POINTER(wintypes.DWORD), # pcchName : DWORD* in/out
ctypes.c_int, # enumRegFlags : SHREGENUM_FLAGS
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHLWAPI.dll')
SHRegEnumUSKeyA = Fiddle::Function.new(
lib['SHRegEnumUSKeyA'],
[
Fiddle::TYPE_INTPTR_T, # hUSKey : INT_PTR
-Fiddle::TYPE_INT, # dwIndex : DWORD
Fiddle::TYPE_VOIDP, # pszName : LPSTR out
Fiddle::TYPE_VOIDP, # pcchName : DWORD* in/out
Fiddle::TYPE_INT, # enumRegFlags : SHREGENUM_FLAGS
],
-Fiddle::TYPE_INT)#[link(name = "shlwapi")]
extern "system" {
fn SHRegEnumUSKeyA(
hUSKey: isize, // INT_PTR
dwIndex: u32, // DWORD
pszName: *mut u8, // LPSTR out
pcchName: *mut u32, // DWORD* 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 SHRegEnumUSKeyA(IntPtr hUSKey, uint dwIndex, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszName, ref uint pcchName, int enumRegFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_SHRegEnumUSKeyA' -Namespace Win32 -PassThru
# $api::SHRegEnumUSKeyA(hUSKey, dwIndex, pszName, pcchName, enumRegFlags)#uselib "SHLWAPI.dll"
#func global SHRegEnumUSKeyA "SHRegEnumUSKeyA" sptr, sptr, sptr, sptr, sptr
; SHRegEnumUSKeyA hUSKey, dwIndex, varptr(pszName), varptr(pcchName), enumRegFlags ; 戻り値は stat
; hUSKey : INT_PTR -> "sptr"
; dwIndex : DWORD -> "sptr"
; pszName : LPSTR out -> "sptr"
; pcchName : DWORD* in/out -> "sptr"
; enumRegFlags : SHREGENUM_FLAGS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHLWAPI.dll" #cfunc global SHRegEnumUSKeyA "SHRegEnumUSKeyA" sptr, int, var, var, int ; res = SHRegEnumUSKeyA(hUSKey, dwIndex, pszName, pcchName, enumRegFlags) ; hUSKey : INT_PTR -> "sptr" ; dwIndex : DWORD -> "int" ; pszName : LPSTR out -> "var" ; pcchName : DWORD* in/out -> "var" ; enumRegFlags : SHREGENUM_FLAGS -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHLWAPI.dll" #cfunc global SHRegEnumUSKeyA "SHRegEnumUSKeyA" sptr, int, sptr, sptr, int ; res = SHRegEnumUSKeyA(hUSKey, dwIndex, varptr(pszName), varptr(pcchName), enumRegFlags) ; hUSKey : INT_PTR -> "sptr" ; dwIndex : DWORD -> "int" ; pszName : LPSTR out -> "sptr" ; pcchName : DWORD* in/out -> "sptr" ; enumRegFlags : SHREGENUM_FLAGS -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; WIN32_ERROR SHRegEnumUSKeyA(INT_PTR hUSKey, DWORD dwIndex, LPSTR pszName, DWORD* pcchName, SHREGENUM_FLAGS enumRegFlags) #uselib "SHLWAPI.dll" #cfunc global SHRegEnumUSKeyA "SHRegEnumUSKeyA" intptr, int, var, var, int ; res = SHRegEnumUSKeyA(hUSKey, dwIndex, pszName, pcchName, enumRegFlags) ; hUSKey : INT_PTR -> "intptr" ; dwIndex : DWORD -> "int" ; pszName : LPSTR out -> "var" ; pcchName : DWORD* in/out -> "var" ; enumRegFlags : SHREGENUM_FLAGS -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WIN32_ERROR SHRegEnumUSKeyA(INT_PTR hUSKey, DWORD dwIndex, LPSTR pszName, DWORD* pcchName, SHREGENUM_FLAGS enumRegFlags) #uselib "SHLWAPI.dll" #cfunc global SHRegEnumUSKeyA "SHRegEnumUSKeyA" intptr, int, intptr, intptr, int ; res = SHRegEnumUSKeyA(hUSKey, dwIndex, varptr(pszName), varptr(pcchName), enumRegFlags) ; hUSKey : INT_PTR -> "intptr" ; dwIndex : DWORD -> "int" ; pszName : LPSTR out -> "intptr" ; pcchName : DWORD* in/out -> "intptr" ; enumRegFlags : SHREGENUM_FLAGS -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procSHRegEnumUSKeyA = shlwapi.NewProc("SHRegEnumUSKeyA")
)
// hUSKey (INT_PTR), dwIndex (DWORD), pszName (LPSTR out), pcchName (DWORD* in/out), enumRegFlags (SHREGENUM_FLAGS)
r1, _, err := procSHRegEnumUSKeyA.Call(
uintptr(hUSKey),
uintptr(dwIndex),
uintptr(pszName),
uintptr(pcchName),
uintptr(enumRegFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction SHRegEnumUSKeyA(
hUSKey: NativeInt; // INT_PTR
dwIndex: DWORD; // DWORD
pszName: PAnsiChar; // LPSTR out
pcchName: Pointer; // DWORD* in/out
enumRegFlags: Integer // SHREGENUM_FLAGS
): DWORD; stdcall;
external 'SHLWAPI.dll' name 'SHRegEnumUSKeyA';result := DllCall("SHLWAPI\SHRegEnumUSKeyA"
, "Ptr", hUSKey ; INT_PTR
, "UInt", dwIndex ; DWORD
, "Ptr", pszName ; LPSTR out
, "Ptr", pcchName ; DWORD* in/out
, "Int", enumRegFlags ; SHREGENUM_FLAGS
, "UInt") ; return: WIN32_ERROR●SHRegEnumUSKeyA(hUSKey, dwIndex, pszName, pcchName, enumRegFlags) = DLL("SHLWAPI.dll", "dword SHRegEnumUSKeyA(int, dword, char*, void*, int)")
# 呼び出し: SHRegEnumUSKeyA(hUSKey, dwIndex, pszName, pcchName, enumRegFlags)
# hUSKey : INT_PTR -> "int"
# dwIndex : DWORD -> "dword"
# pszName : LPSTR out -> "char*"
# pcchName : DWORD* in/out -> "void*"
# enumRegFlags : SHREGENUM_FLAGS -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。