SHGetValueW
関数サブキーと値名を指定してレジストリの値を取得する。
シグネチャ
// SHLWAPI.dll (Unicode / -W)
#include <windows.h>
WIN32_ERROR SHGetValueW(
HKEY hkey,
LPCWSTR pszSubKey, // optional
LPCWSTR pszValue, // optional
DWORD* pdwType, // optional
void* pvData, // optional
DWORD* pcbData // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hkey | HKEY | in | 現在開いているキーへのハンドル、または次の定義済みの値のいずれか。 HKEY_CLASSES_ROOTHKEY_CURRENT_CONFIGHKEY_CURRENT_USERHKEY_LOCAL_MACHINEHKEY_PERFORMANCE_DATAHKEY_USERS |
| pszSubKey | LPCWSTR | inoptional | 値を取得するサブキーの名前を指定する、null で終わる文字列のアドレス。 |
| pszValue | LPCWSTR | inoptional | 値のアドレス。 |
| pdwType | DWORD* | outoptional | 値の型。詳細については、Registry Data Types を参照してください。 |
| pvData | void* | outoptional | 格納先データバッファーのアドレス。 |
| pcbData | DWORD* | inoutoptional | 格納先データバッファーのサイズ。 - hkey.HKEY_CLASSES_ROOT- hkey.HKEY_CURRENT_CONFIG- hkey.HKEY_CURRENT_USER- hkey.HKEY_LOCAL_MACHINE- hkey.HKEY_PERFORMANCE_DATA- hkey.HKEY_USERS |
戻り値の型: WIN32_ERROR
公式ドキュメント
レジストリの値を取得します。(SHGetValueW)
戻り値
型: LSTATUS
成功した場合は ERROR_SUCCESS を返し、それ以外の場合は Winerror.h で定義された 0 以外のエラーコードを返します。FormatMessage 関数を FORMAT_MESSAGE_FROM_SYSTEM フラグとともに使用すると、エラーの一般的な説明を取得できます。
解説(Remarks)
アプリケーションが同じキー内の一連の値を設定または取得する必要がある場合は、この関数を繰り返し使用するよりも、キーを一度開いて通常の Microsoft Win32 レジストリ関数で値を設定または取得する方が適切です。
メモ
shlwapi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして SHGetValue を定義します。エンコーディング非依存のエイリアスを、エンコーディング非依存でないコードと混在させて使用すると、不一致が生じ、コンパイルエラーまたは実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// SHLWAPI.dll (Unicode / -W)
#include <windows.h>
WIN32_ERROR SHGetValueW(
HKEY hkey,
LPCWSTR pszSubKey, // optional
LPCWSTR pszValue, // optional
DWORD* pdwType, // optional
void* pvData, // optional
DWORD* pcbData // optional
);[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint SHGetValueW(
IntPtr hkey, // HKEY
[MarshalAs(UnmanagedType.LPWStr)] string pszSubKey, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string pszValue, // LPCWSTR optional
IntPtr pdwType, // DWORD* optional, out
IntPtr pvData, // void* optional, out
IntPtr pcbData // DWORD* optional, in/out
);<DllImport("SHLWAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SHGetValueW(
hkey As IntPtr, ' HKEY
<MarshalAs(UnmanagedType.LPWStr)> pszSubKey As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> pszValue As String, ' LPCWSTR optional
pdwType As IntPtr, ' DWORD* optional, out
pvData As IntPtr, ' void* optional, out
pcbData As IntPtr ' DWORD* optional, in/out
) As UInteger
End Function' hkey : HKEY
' pszSubKey : LPCWSTR optional
' pszValue : LPCWSTR optional
' pdwType : DWORD* optional, out
' pvData : void* optional, out
' pcbData : DWORD* optional, in/out
Declare PtrSafe Function SHGetValueW Lib "shlwapi" ( _
ByVal hkey As LongPtr, _
ByVal pszSubKey As LongPtr, _
ByVal pszValue As LongPtr, _
ByVal pdwType As LongPtr, _
ByVal pvData As LongPtr, _
ByVal pcbData As LongPtr) 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
SHGetValueW = ctypes.windll.shlwapi.SHGetValueW
SHGetValueW.restype = wintypes.DWORD
SHGetValueW.argtypes = [
wintypes.HANDLE, # hkey : HKEY
wintypes.LPCWSTR, # pszSubKey : LPCWSTR optional
wintypes.LPCWSTR, # pszValue : LPCWSTR optional
ctypes.POINTER(wintypes.DWORD), # pdwType : DWORD* optional, out
ctypes.POINTER(None), # pvData : void* optional, out
ctypes.POINTER(wintypes.DWORD), # pcbData : DWORD* optional, in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHLWAPI.dll')
SHGetValueW = Fiddle::Function.new(
lib['SHGetValueW'],
[
Fiddle::TYPE_VOIDP, # hkey : HKEY
Fiddle::TYPE_VOIDP, # pszSubKey : LPCWSTR optional
Fiddle::TYPE_VOIDP, # pszValue : LPCWSTR optional
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)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "shlwapi")]
extern "system" {
fn SHGetValueW(
hkey: *mut core::ffi::c_void, // HKEY
pszSubKey: *const u16, // LPCWSTR optional
pszValue: *const u16, // LPCWSTR optional
pdwType: *mut u32, // DWORD* optional, out
pvData: *mut (), // void* optional, out
pcbData: *mut u32 // DWORD* optional, in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode)]
public static extern uint SHGetValueW(IntPtr hkey, [MarshalAs(UnmanagedType.LPWStr)] string pszSubKey, [MarshalAs(UnmanagedType.LPWStr)] string pszValue, IntPtr pdwType, IntPtr pvData, IntPtr pcbData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_SHGetValueW' -Namespace Win32 -PassThru
# $api::SHGetValueW(hkey, pszSubKey, pszValue, pdwType, pvData, pcbData)#uselib "SHLWAPI.dll"
#func global SHGetValueW "SHGetValueW" wptr, wptr, wptr, wptr, wptr, wptr
; SHGetValueW hkey, pszSubKey, pszValue, varptr(pdwType), pvData, varptr(pcbData) ; 戻り値は stat
; hkey : HKEY -> "wptr"
; pszSubKey : LPCWSTR optional -> "wptr"
; pszValue : LPCWSTR optional -> "wptr"
; pdwType : DWORD* optional, out -> "wptr"
; pvData : void* optional, out -> "wptr"
; pcbData : DWORD* optional, in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHLWAPI.dll" #cfunc global SHGetValueW "SHGetValueW" sptr, wstr, wstr, var, sptr, var ; res = SHGetValueW(hkey, pszSubKey, pszValue, pdwType, pvData, pcbData) ; hkey : HKEY -> "sptr" ; pszSubKey : LPCWSTR optional -> "wstr" ; pszValue : LPCWSTR optional -> "wstr" ; pdwType : DWORD* optional, out -> "var" ; pvData : void* optional, out -> "sptr" ; pcbData : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHLWAPI.dll" #cfunc global SHGetValueW "SHGetValueW" sptr, wstr, wstr, sptr, sptr, sptr ; res = SHGetValueW(hkey, pszSubKey, pszValue, varptr(pdwType), pvData, varptr(pcbData)) ; hkey : HKEY -> "sptr" ; pszSubKey : LPCWSTR optional -> "wstr" ; pszValue : LPCWSTR optional -> "wstr" ; pdwType : DWORD* optional, out -> "sptr" ; pvData : void* optional, out -> "sptr" ; pcbData : DWORD* optional, in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; WIN32_ERROR SHGetValueW(HKEY hkey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD* pdwType, void* pvData, DWORD* pcbData) #uselib "SHLWAPI.dll" #cfunc global SHGetValueW "SHGetValueW" intptr, wstr, wstr, var, intptr, var ; res = SHGetValueW(hkey, pszSubKey, pszValue, pdwType, pvData, pcbData) ; hkey : HKEY -> "intptr" ; pszSubKey : LPCWSTR optional -> "wstr" ; pszValue : LPCWSTR optional -> "wstr" ; pdwType : DWORD* optional, out -> "var" ; pvData : void* optional, out -> "intptr" ; pcbData : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WIN32_ERROR SHGetValueW(HKEY hkey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD* pdwType, void* pvData, DWORD* pcbData) #uselib "SHLWAPI.dll" #cfunc global SHGetValueW "SHGetValueW" intptr, wstr, wstr, intptr, intptr, intptr ; res = SHGetValueW(hkey, pszSubKey, pszValue, varptr(pdwType), pvData, varptr(pcbData)) ; hkey : HKEY -> "intptr" ; pszSubKey : LPCWSTR optional -> "wstr" ; pszValue : LPCWSTR optional -> "wstr" ; pdwType : DWORD* optional, out -> "intptr" ; pvData : void* optional, out -> "intptr" ; pcbData : DWORD* optional, in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procSHGetValueW = shlwapi.NewProc("SHGetValueW")
)
// hkey (HKEY), pszSubKey (LPCWSTR optional), pszValue (LPCWSTR optional), pdwType (DWORD* optional, out), pvData (void* optional, out), pcbData (DWORD* optional, in/out)
r1, _, err := procSHGetValueW.Call(
uintptr(hkey),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszSubKey))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszValue))),
uintptr(pdwType),
uintptr(pvData),
uintptr(pcbData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction SHGetValueW(
hkey: THandle; // HKEY
pszSubKey: PWideChar; // LPCWSTR optional
pszValue: PWideChar; // LPCWSTR optional
pdwType: Pointer; // DWORD* optional, out
pvData: Pointer; // void* optional, out
pcbData: Pointer // DWORD* optional, in/out
): DWORD; stdcall;
external 'SHLWAPI.dll' name 'SHGetValueW';result := DllCall("SHLWAPI\SHGetValueW"
, "Ptr", hkey ; HKEY
, "WStr", pszSubKey ; LPCWSTR optional
, "WStr", pszValue ; LPCWSTR optional
, "Ptr", pdwType ; DWORD* optional, out
, "Ptr", pvData ; void* optional, out
, "Ptr", pcbData ; DWORD* optional, in/out
, "UInt") ; return: WIN32_ERROR●SHGetValueW(hkey, pszSubKey, pszValue, pdwType, pvData, pcbData) = DLL("SHLWAPI.dll", "dword SHGetValueW(void*, char*, char*, void*, void*, void*)")
# 呼び出し: SHGetValueW(hkey, pszSubKey, pszValue, pdwType, pvData, pcbData)
# hkey : HKEY -> "void*"
# pszSubKey : LPCWSTR optional -> "char*"
# pszValue : LPCWSTR optional -> "char*"
# pdwType : DWORD* optional, out -> "void*"
# pvData : void* optional, out -> "void*"
# pcbData : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "shlwapi" fn SHGetValueW(
hkey: ?*anyopaque, // HKEY
pszSubKey: [*c]const u16, // LPCWSTR optional
pszValue: [*c]const u16, // LPCWSTR optional
pdwType: [*c]u32, // DWORD* optional, out
pvData: ?*anyopaque, // void* optional, out
pcbData: [*c]u32 // DWORD* optional, in/out
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc SHGetValueW(
hkey: pointer, # HKEY
pszSubKey: WideCString, # LPCWSTR optional
pszValue: WideCString, # LPCWSTR optional
pdwType: ptr uint32, # DWORD* optional, out
pvData: pointer, # void* optional, out
pcbData: ptr uint32 # DWORD* optional, in/out
): uint32 {.importc: "SHGetValueW", stdcall, dynlib: "SHLWAPI.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "shlwapi");
extern(Windows)
uint SHGetValueW(
void* hkey, // HKEY
const(wchar)* pszSubKey, // LPCWSTR optional
const(wchar)* pszValue, // LPCWSTR optional
uint* pdwType, // DWORD* optional, out
void* pvData, // void* optional, out
uint* pcbData // DWORD* optional, in/out
);ccall((:SHGetValueW, "SHLWAPI.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Cwstring, Cwstring, Ptr{UInt32}, Ptr{Cvoid}, Ptr{UInt32}),
hkey, pszSubKey, pszValue, pdwType, pvData, pcbData)
# hkey : HKEY -> Ptr{Cvoid}
# pszSubKey : LPCWSTR optional -> Cwstring
# pszValue : LPCWSTR optional -> Cwstring
# pdwType : DWORD* optional, out -> Ptr{UInt32}
# pvData : void* optional, out -> Ptr{Cvoid}
# pcbData : DWORD* optional, in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
uint32_t SHGetValueW(
void* hkey,
const uint16_t* pszSubKey,
const uint16_t* pszValue,
uint32_t* pdwType,
void* pvData,
uint32_t* pcbData);
]]
local shlwapi = ffi.load("shlwapi")
-- shlwapi.SHGetValueW(hkey, pszSubKey, pszValue, pdwType, pvData, pcbData)
-- hkey : HKEY
-- pszSubKey : LPCWSTR optional
-- pszValue : LPCWSTR optional
-- pdwType : DWORD* optional, out
-- pvData : void* optional, out
-- pcbData : DWORD* optional, in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('SHLWAPI.dll');
const SHGetValueW = lib.func('__stdcall', 'SHGetValueW', 'uint32_t', ['void *', 'str16', 'str16', 'uint32_t *', 'void *', 'uint32_t *']);
// SHGetValueW(hkey, pszSubKey, pszValue, pdwType, pvData, pcbData)
// hkey : HKEY -> 'void *'
// pszSubKey : LPCWSTR optional -> 'str16'
// pszValue : LPCWSTR optional -> 'str16'
// pdwType : DWORD* optional, out -> 'uint32_t *'
// pvData : void* optional, out -> 'void *'
// pcbData : DWORD* optional, in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SHLWAPI.dll", {
SHGetValueW: { parameters: ["pointer", "buffer", "buffer", "pointer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.SHGetValueW(hkey, pszSubKey, pszValue, pdwType, pvData, pcbData)
// hkey : HKEY -> "pointer"
// pszSubKey : LPCWSTR optional -> "buffer"
// pszValue : LPCWSTR optional -> "buffer"
// pdwType : DWORD* optional, out -> "pointer"
// pvData : void* optional, out -> "pointer"
// pcbData : DWORD* optional, in/out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t SHGetValueW(
void* hkey,
const uint16_t* pszSubKey,
const uint16_t* pszValue,
uint32_t* pdwType,
void* pvData,
uint32_t* pcbData);
C, "SHLWAPI.dll");
// $ffi->SHGetValueW(hkey, pszSubKey, pszValue, pdwType, pvData, pcbData);
// hkey : HKEY
// pszSubKey : LPCWSTR optional
// pszValue : LPCWSTR optional
// pdwType : DWORD* optional, out
// pvData : void* optional, out
// pcbData : DWORD* optional, in/out
// 構造体/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 Shlwapi extends StdCallLibrary {
Shlwapi INSTANCE = Native.load("shlwapi", Shlwapi.class, W32APIOptions.UNICODE_OPTIONS);
int SHGetValueW(
Pointer hkey, // HKEY
WString pszSubKey, // LPCWSTR optional
WString pszValue, // LPCWSTR optional
IntByReference pdwType, // DWORD* optional, out
Pointer pvData, // void* optional, out
IntByReference pcbData // DWORD* optional, in/out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("shlwapi")]
lib LibSHLWAPI
fun SHGetValueW = SHGetValueW(
hkey : Void*, # HKEY
pszSubKey : UInt16*, # LPCWSTR optional
pszValue : UInt16*, # LPCWSTR optional
pdwType : UInt32*, # DWORD* optional, out
pvData : Void*, # void* optional, out
pcbData : UInt32* # DWORD* optional, in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SHGetValueWNative = Uint32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>, Pointer<Void>, Pointer<Uint32>);
typedef SHGetValueWDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>, Pointer<Void>, Pointer<Uint32>);
final SHGetValueW = DynamicLibrary.open('SHLWAPI.dll')
.lookupFunction<SHGetValueWNative, SHGetValueWDart>('SHGetValueW');
// hkey : HKEY -> Pointer<Void>
// pszSubKey : LPCWSTR optional -> Pointer<Utf16>
// pszValue : LPCWSTR optional -> Pointer<Utf16>
// pdwType : DWORD* optional, out -> Pointer<Uint32>
// pvData : void* optional, out -> Pointer<Void>
// pcbData : DWORD* optional, in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SHGetValueW(
hkey: THandle; // HKEY
pszSubKey: PWideChar; // LPCWSTR optional
pszValue: PWideChar; // LPCWSTR optional
pdwType: Pointer; // DWORD* optional, out
pvData: Pointer; // void* optional, out
pcbData: Pointer // DWORD* optional, in/out
): DWORD; stdcall;
external 'SHLWAPI.dll' name 'SHGetValueW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SHGetValueW"
c_SHGetValueW :: Ptr () -> CWString -> CWString -> Ptr Word32 -> Ptr () -> Ptr Word32 -> IO Word32
-- hkey : HKEY -> Ptr ()
-- pszSubKey : LPCWSTR optional -> CWString
-- pszValue : LPCWSTR optional -> CWString
-- pdwType : DWORD* optional, out -> Ptr Word32
-- pvData : void* optional, out -> Ptr ()
-- pcbData : DWORD* optional, in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let shgetvaluew =
foreign "SHGetValueW"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> (ptr void) @-> (ptr uint32_t) @-> returning uint32_t)
(* hkey : HKEY -> (ptr void) *)
(* pszSubKey : LPCWSTR optional -> (ptr uint16_t) *)
(* pszValue : LPCWSTR optional -> (ptr uint16_t) *)
(* pdwType : DWORD* optional, out -> (ptr uint32_t) *)
(* pvData : void* optional, out -> (ptr void) *)
(* pcbData : DWORD* optional, in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library shlwapi (t "SHLWAPI.dll"))
(cffi:use-foreign-library shlwapi)
(cffi:defcfun ("SHGetValueW" shget-value-w :convention :stdcall) :uint32
(hkey :pointer) ; HKEY
(psz-sub-key (:string :encoding :utf-16le)) ; LPCWSTR optional
(psz-value (:string :encoding :utf-16le)) ; LPCWSTR optional
(pdw-type :pointer) ; DWORD* optional, out
(pv-data :pointer) ; void* optional, out
(pcb-data :pointer)) ; DWORD* optional, in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SHGetValueW = Win32::API::More->new('SHLWAPI',
'DWORD SHGetValueW(HANDLE hkey, LPCWSTR pszSubKey, LPCWSTR pszValue, LPVOID pdwType, LPVOID pvData, LPVOID pcbData)');
# my $ret = $SHGetValueW->Call($hkey, $pszSubKey, $pszValue, $pdwType, $pvData, $pcbData);
# hkey : HKEY -> HANDLE
# pszSubKey : LPCWSTR optional -> LPCWSTR
# pszValue : LPCWSTR optional -> LPCWSTR
# pdwType : DWORD* optional, out -> LPVOID
# pvData : void* optional, out -> LPVOID
# pcbData : DWORD* optional, in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f SHGetValueA (ANSI版) — サブキーと値名を指定してレジストリの値を取得する。
使用する型