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