OpenRegStream
関数レジストリ値を読み書きするIStreamを開く。
シグネチャ
// SHELL32.dll
#include <windows.h>
IStream* OpenRegStream(
HKEY hkey,
LPCWSTR pszSubkey, // optional
LPCWSTR pszValue, // optional
DWORD grfMode
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hkey | HKEY | in |
| pszSubkey | LPCWSTR | inoptional |
| pszValue | LPCWSTR | inoptional |
| grfMode | DWORD | in |
戻り値の型: IStream*
各言語での呼び出し定義
// SHELL32.dll
#include <windows.h>
IStream* OpenRegStream(
HKEY hkey,
LPCWSTR pszSubkey, // optional
LPCWSTR pszValue, // optional
DWORD grfMode
);[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern IntPtr OpenRegStream(
IntPtr hkey, // HKEY
[MarshalAs(UnmanagedType.LPWStr)] string pszSubkey, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string pszValue, // LPCWSTR optional
uint grfMode // DWORD
);<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function OpenRegStream(
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 OpenRegStream Lib "shell32" ( _
ByVal hkey As LongPtr, _
ByVal pszSubkey As LongPtr, _
ByVal pszValue As LongPtr, _
ByVal grfMode As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
OpenRegStream = ctypes.windll.shell32.OpenRegStream
OpenRegStream.restype = ctypes.c_void_p
OpenRegStream.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('SHELL32.dll')
OpenRegStream = Fiddle::Function.new(
lib['OpenRegStream'],
[
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)#[link(name = "shell32")]
extern "system" {
fn OpenRegStream(
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("SHELL32.dll")]
public static extern IntPtr OpenRegStream(IntPtr hkey, [MarshalAs(UnmanagedType.LPWStr)] string pszSubkey, [MarshalAs(UnmanagedType.LPWStr)] string pszValue, uint grfMode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_OpenRegStream' -Namespace Win32 -PassThru
# $api::OpenRegStream(hkey, pszSubkey, pszValue, grfMode)#uselib "SHELL32.dll"
#func global OpenRegStream "OpenRegStream" sptr, sptr, sptr, sptr
; OpenRegStream hkey, pszSubkey, pszValue, grfMode ; 戻り値は stat
; hkey : HKEY -> "sptr"
; pszSubkey : LPCWSTR optional -> "sptr"
; pszValue : LPCWSTR optional -> "sptr"
; grfMode : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHELL32.dll"
#cfunc global OpenRegStream "OpenRegStream" sptr, wstr, wstr, int
; res = OpenRegStream(hkey, pszSubkey, pszValue, grfMode)
; hkey : HKEY -> "sptr"
; pszSubkey : LPCWSTR optional -> "wstr"
; pszValue : LPCWSTR optional -> "wstr"
; grfMode : DWORD -> "int"; IStream* OpenRegStream(HKEY hkey, LPCWSTR pszSubkey, LPCWSTR pszValue, DWORD grfMode)
#uselib "SHELL32.dll"
#cfunc global OpenRegStream "OpenRegStream" intptr, wstr, wstr, int
; res = OpenRegStream(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 (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procOpenRegStream = shell32.NewProc("OpenRegStream")
)
// hkey (HKEY), pszSubkey (LPCWSTR optional), pszValue (LPCWSTR optional), grfMode (DWORD)
r1, _, err := procOpenRegStream.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 OpenRegStream(
hkey: THandle; // HKEY
pszSubkey: PWideChar; // LPCWSTR optional
pszValue: PWideChar; // LPCWSTR optional
grfMode: DWORD // DWORD
): Pointer; stdcall;
external 'SHELL32.dll' name 'OpenRegStream';result := DllCall("SHELL32\OpenRegStream"
, "Ptr", hkey ; HKEY
, "WStr", pszSubkey ; LPCWSTR optional
, "WStr", pszValue ; LPCWSTR optional
, "UInt", grfMode ; DWORD
, "Ptr") ; return: IStream*●OpenRegStream(hkey, pszSubkey, pszValue, grfMode) = DLL("SHELL32.dll", "void* OpenRegStream(void*, char*, char*, dword)")
# 呼び出し: OpenRegStream(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)。