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