ホーム › Networking.Clustering › ResUtilSetValueEx
ResUtilSetValueEx
関数型とフラグを指定してクラスタキーに値を設定する。
シグネチャ
// RESUTILS.dll
#include <windows.h>
DWORD ResUtilSetValueEx(
HKEY hkeyClusterKey,
LPCWSTR valueName,
DWORD valueType,
const BYTE* valueData,
DWORD valueSize,
DWORD flags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hkeyClusterKey | HKEY | in |
| valueName | LPCWSTR | in |
| valueType | DWORD | in |
| valueData | BYTE* | in |
| valueSize | DWORD | in |
| flags | DWORD | in |
戻り値の型: DWORD
各言語での呼び出し定義
// RESUTILS.dll
#include <windows.h>
DWORD ResUtilSetValueEx(
HKEY hkeyClusterKey,
LPCWSTR valueName,
DWORD valueType,
const BYTE* valueData,
DWORD valueSize,
DWORD flags
);[DllImport("RESUTILS.dll", ExactSpelling = true)]
static extern uint ResUtilSetValueEx(
IntPtr hkeyClusterKey, // HKEY
[MarshalAs(UnmanagedType.LPWStr)] string valueName, // LPCWSTR
uint valueType, // DWORD
IntPtr valueData, // BYTE*
uint valueSize, // DWORD
uint flags // DWORD
);<DllImport("RESUTILS.dll", ExactSpelling:=True)>
Public Shared Function ResUtilSetValueEx(
hkeyClusterKey As IntPtr, ' HKEY
<MarshalAs(UnmanagedType.LPWStr)> valueName As String, ' LPCWSTR
valueType As UInteger, ' DWORD
valueData As IntPtr, ' BYTE*
valueSize As UInteger, ' DWORD
flags As UInteger ' DWORD
) As UInteger
End Function' hkeyClusterKey : HKEY
' valueName : LPCWSTR
' valueType : DWORD
' valueData : BYTE*
' valueSize : DWORD
' flags : DWORD
Declare PtrSafe Function ResUtilSetValueEx Lib "resutils" ( _
ByVal hkeyClusterKey As LongPtr, _
ByVal valueName As LongPtr, _
ByVal valueType As Long, _
ByVal valueData As LongPtr, _
ByVal valueSize As Long, _
ByVal flags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ResUtilSetValueEx = ctypes.windll.resutils.ResUtilSetValueEx
ResUtilSetValueEx.restype = wintypes.DWORD
ResUtilSetValueEx.argtypes = [
wintypes.HANDLE, # hkeyClusterKey : HKEY
wintypes.LPCWSTR, # valueName : LPCWSTR
wintypes.DWORD, # valueType : DWORD
ctypes.POINTER(ctypes.c_ubyte), # valueData : BYTE*
wintypes.DWORD, # valueSize : DWORD
wintypes.DWORD, # flags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RESUTILS.dll')
ResUtilSetValueEx = Fiddle::Function.new(
lib['ResUtilSetValueEx'],
[
Fiddle::TYPE_VOIDP, # hkeyClusterKey : HKEY
Fiddle::TYPE_VOIDP, # valueName : LPCWSTR
-Fiddle::TYPE_INT, # valueType : DWORD
Fiddle::TYPE_VOIDP, # valueData : BYTE*
-Fiddle::TYPE_INT, # valueSize : DWORD
-Fiddle::TYPE_INT, # flags : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "resutils")]
extern "system" {
fn ResUtilSetValueEx(
hkeyClusterKey: *mut core::ffi::c_void, // HKEY
valueName: *const u16, // LPCWSTR
valueType: u32, // DWORD
valueData: *const u8, // BYTE*
valueSize: u32, // DWORD
flags: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RESUTILS.dll")]
public static extern uint ResUtilSetValueEx(IntPtr hkeyClusterKey, [MarshalAs(UnmanagedType.LPWStr)] string valueName, uint valueType, IntPtr valueData, uint valueSize, uint flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RESUTILS_ResUtilSetValueEx' -Namespace Win32 -PassThru
# $api::ResUtilSetValueEx(hkeyClusterKey, valueName, valueType, valueData, valueSize, flags)#uselib "RESUTILS.dll"
#func global ResUtilSetValueEx "ResUtilSetValueEx" sptr, sptr, sptr, sptr, sptr, sptr
; ResUtilSetValueEx hkeyClusterKey, valueName, valueType, varptr(valueData), valueSize, flags ; 戻り値は stat
; hkeyClusterKey : HKEY -> "sptr"
; valueName : LPCWSTR -> "sptr"
; valueType : DWORD -> "sptr"
; valueData : BYTE* -> "sptr"
; valueSize : DWORD -> "sptr"
; flags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "RESUTILS.dll" #cfunc global ResUtilSetValueEx "ResUtilSetValueEx" sptr, wstr, int, var, int, int ; res = ResUtilSetValueEx(hkeyClusterKey, valueName, valueType, valueData, valueSize, flags) ; hkeyClusterKey : HKEY -> "sptr" ; valueName : LPCWSTR -> "wstr" ; valueType : DWORD -> "int" ; valueData : BYTE* -> "var" ; valueSize : DWORD -> "int" ; flags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RESUTILS.dll" #cfunc global ResUtilSetValueEx "ResUtilSetValueEx" sptr, wstr, int, sptr, int, int ; res = ResUtilSetValueEx(hkeyClusterKey, valueName, valueType, varptr(valueData), valueSize, flags) ; hkeyClusterKey : HKEY -> "sptr" ; valueName : LPCWSTR -> "wstr" ; valueType : DWORD -> "int" ; valueData : BYTE* -> "sptr" ; valueSize : DWORD -> "int" ; flags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD ResUtilSetValueEx(HKEY hkeyClusterKey, LPCWSTR valueName, DWORD valueType, BYTE* valueData, DWORD valueSize, DWORD flags) #uselib "RESUTILS.dll" #cfunc global ResUtilSetValueEx "ResUtilSetValueEx" intptr, wstr, int, var, int, int ; res = ResUtilSetValueEx(hkeyClusterKey, valueName, valueType, valueData, valueSize, flags) ; hkeyClusterKey : HKEY -> "intptr" ; valueName : LPCWSTR -> "wstr" ; valueType : DWORD -> "int" ; valueData : BYTE* -> "var" ; valueSize : DWORD -> "int" ; flags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD ResUtilSetValueEx(HKEY hkeyClusterKey, LPCWSTR valueName, DWORD valueType, BYTE* valueData, DWORD valueSize, DWORD flags) #uselib "RESUTILS.dll" #cfunc global ResUtilSetValueEx "ResUtilSetValueEx" intptr, wstr, int, intptr, int, int ; res = ResUtilSetValueEx(hkeyClusterKey, valueName, valueType, varptr(valueData), valueSize, flags) ; hkeyClusterKey : HKEY -> "intptr" ; valueName : LPCWSTR -> "wstr" ; valueType : DWORD -> "int" ; valueData : BYTE* -> "intptr" ; valueSize : DWORD -> "int" ; flags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
resutils = windows.NewLazySystemDLL("RESUTILS.dll")
procResUtilSetValueEx = resutils.NewProc("ResUtilSetValueEx")
)
// hkeyClusterKey (HKEY), valueName (LPCWSTR), valueType (DWORD), valueData (BYTE*), valueSize (DWORD), flags (DWORD)
r1, _, err := procResUtilSetValueEx.Call(
uintptr(hkeyClusterKey),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(valueName))),
uintptr(valueType),
uintptr(valueData),
uintptr(valueSize),
uintptr(flags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction ResUtilSetValueEx(
hkeyClusterKey: THandle; // HKEY
valueName: PWideChar; // LPCWSTR
valueType: DWORD; // DWORD
valueData: Pointer; // BYTE*
valueSize: DWORD; // DWORD
flags: DWORD // DWORD
): DWORD; stdcall;
external 'RESUTILS.dll' name 'ResUtilSetValueEx';result := DllCall("RESUTILS\ResUtilSetValueEx"
, "Ptr", hkeyClusterKey ; HKEY
, "WStr", valueName ; LPCWSTR
, "UInt", valueType ; DWORD
, "Ptr", valueData ; BYTE*
, "UInt", valueSize ; DWORD
, "UInt", flags ; DWORD
, "UInt") ; return: DWORD●ResUtilSetValueEx(hkeyClusterKey, valueName, valueType, valueData, valueSize, flags) = DLL("RESUTILS.dll", "dword ResUtilSetValueEx(void*, char*, dword, void*, dword, dword)")
# 呼び出し: ResUtilSetValueEx(hkeyClusterKey, valueName, valueType, valueData, valueSize, flags)
# hkeyClusterKey : HKEY -> "void*"
# valueName : LPCWSTR -> "char*"
# valueType : DWORD -> "dword"
# valueData : BYTE* -> "void*"
# valueSize : DWORD -> "dword"
# flags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。