SHOpenRegStreamW
関数レジストリ値の内容を読み書きするストリームを開く。
シグネチャ
// SHLWAPI.dll (Unicode / -W)
#include <windows.h>
IStream* SHOpenRegStreamW(
HKEY hkey,
LPCWSTR pszSubkey, // optional
LPCWSTR pszValue, // optional
DWORD grfMode
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hkey | HKEY | in |
| pszSubkey | LPCWSTR | inoptional |
| pszValue | LPCWSTR | inoptional |
| grfMode | DWORD | in |
戻り値の型: IStream*
各言語での呼び出し定義
// SHLWAPI.dll (Unicode / -W)
#include <windows.h>
IStream* SHOpenRegStreamW(
HKEY hkey,
LPCWSTR pszSubkey, // optional
LPCWSTR pszValue, // optional
DWORD grfMode
);[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern IntPtr SHOpenRegStreamW(
IntPtr hkey, // HKEY
[MarshalAs(UnmanagedType.LPWStr)] string pszSubkey, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string pszValue, // LPCWSTR optional
uint grfMode // DWORD
);<DllImport("SHLWAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SHOpenRegStreamW(
hkey As IntPtr, ' HKEY
<MarshalAs(UnmanagedType.LPWStr)> pszSubkey As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> pszValue As String, ' LPCWSTR optional
grfMode As UInteger ' DWORD
) As IntPtr
End Function' hkey : HKEY
' pszSubkey : LPCWSTR optional
' pszValue : LPCWSTR optional
' grfMode : DWORD
Declare PtrSafe Function SHOpenRegStreamW Lib "shlwapi" ( _
ByVal hkey As LongPtr, _
ByVal pszSubkey As LongPtr, _
ByVal pszValue As LongPtr, _
ByVal grfMode As Long) As LongPtr
' 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
SHOpenRegStreamW = ctypes.windll.shlwapi.SHOpenRegStreamW
SHOpenRegStreamW.restype = ctypes.c_void_p
SHOpenRegStreamW.argtypes = [
wintypes.HANDLE, # hkey : HKEY
wintypes.LPCWSTR, # pszSubkey : LPCWSTR optional
wintypes.LPCWSTR, # pszValue : LPCWSTR optional
wintypes.DWORD, # grfMode : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHLWAPI.dll')
SHOpenRegStreamW = Fiddle::Function.new(
lib['SHOpenRegStreamW'],
[
Fiddle::TYPE_VOIDP, # hkey : HKEY
Fiddle::TYPE_VOIDP, # pszSubkey : LPCWSTR optional
Fiddle::TYPE_VOIDP, # pszValue : LPCWSTR optional
-Fiddle::TYPE_INT, # grfMode : DWORD
],
Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "shlwapi")]
extern "system" {
fn SHOpenRegStreamW(
hkey: *mut core::ffi::c_void, // HKEY
pszSubkey: *const u16, // LPCWSTR optional
pszValue: *const u16, // LPCWSTR optional
grfMode: u32 // DWORD
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr SHOpenRegStreamW(IntPtr hkey, [MarshalAs(UnmanagedType.LPWStr)] string pszSubkey, [MarshalAs(UnmanagedType.LPWStr)] string pszValue, uint grfMode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_SHOpenRegStreamW' -Namespace Win32 -PassThru
# $api::SHOpenRegStreamW(hkey, pszSubkey, pszValue, grfMode)#uselib "SHLWAPI.dll"
#func global SHOpenRegStreamW "SHOpenRegStreamW" wptr, wptr, wptr, wptr
; SHOpenRegStreamW hkey, pszSubkey, pszValue, grfMode ; 戻り値は stat
; hkey : HKEY -> "wptr"
; pszSubkey : LPCWSTR optional -> "wptr"
; pszValue : LPCWSTR optional -> "wptr"
; grfMode : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHLWAPI.dll"
#cfunc global SHOpenRegStreamW "SHOpenRegStreamW" sptr, wstr, wstr, int
; res = SHOpenRegStreamW(hkey, pszSubkey, pszValue, grfMode)
; hkey : HKEY -> "sptr"
; pszSubkey : LPCWSTR optional -> "wstr"
; pszValue : LPCWSTR optional -> "wstr"
; grfMode : DWORD -> "int"; IStream* SHOpenRegStreamW(HKEY hkey, LPCWSTR pszSubkey, LPCWSTR pszValue, DWORD grfMode)
#uselib "SHLWAPI.dll"
#cfunc global SHOpenRegStreamW "SHOpenRegStreamW" intptr, wstr, wstr, int
; res = SHOpenRegStreamW(hkey, pszSubkey, pszValue, grfMode)
; hkey : HKEY -> "intptr"
; pszSubkey : LPCWSTR optional -> "wstr"
; pszValue : LPCWSTR optional -> "wstr"
; grfMode : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procSHOpenRegStreamW = shlwapi.NewProc("SHOpenRegStreamW")
)
// hkey (HKEY), pszSubkey (LPCWSTR optional), pszValue (LPCWSTR optional), grfMode (DWORD)
r1, _, err := procSHOpenRegStreamW.Call(
uintptr(hkey),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszSubkey))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszValue))),
uintptr(grfMode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // IStream*function SHOpenRegStreamW(
hkey: THandle; // HKEY
pszSubkey: PWideChar; // LPCWSTR optional
pszValue: PWideChar; // LPCWSTR optional
grfMode: DWORD // DWORD
): Pointer; stdcall;
external 'SHLWAPI.dll' name 'SHOpenRegStreamW';result := DllCall("SHLWAPI\SHOpenRegStreamW"
, "Ptr", hkey ; HKEY
, "WStr", pszSubkey ; LPCWSTR optional
, "WStr", pszValue ; LPCWSTR optional
, "UInt", grfMode ; DWORD
, "Ptr") ; return: IStream*●SHOpenRegStreamW(hkey, pszSubkey, pszValue, grfMode) = DLL("SHLWAPI.dll", "void* SHOpenRegStreamW(void*, char*, char*, dword)")
# 呼び出し: SHOpenRegStreamW(hkey, pszSubkey, pszValue, grfMode)
# hkey : HKEY -> "void*"
# pszSubkey : LPCWSTR optional -> "char*"
# pszValue : LPCWSTR optional -> "char*"
# grfMode : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。