Win32 API 日本語リファレンス
ホームNetworking.Clustering › ResUtilSetDwordValue

ResUtilSetDwordValue

関数
クラスタキーにDWORD値を設定する。
DLLRESUTILS.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

// RESUTILS.dll
#include <windows.h>

DWORD ResUtilSetDwordValue(
    HKEY hkeyClusterKey,
    LPCWSTR pszValueName,
    DWORD dwNewValue,
    DWORD* pdwOutValue
);

パラメーター

名前方向
hkeyClusterKeyHKEYin
pszValueNameLPCWSTRin
dwNewValueDWORDin
pdwOutValueDWORD*inout

戻り値の型: DWORD

各言語での呼び出し定義

// RESUTILS.dll
#include <windows.h>

DWORD ResUtilSetDwordValue(
    HKEY hkeyClusterKey,
    LPCWSTR pszValueName,
    DWORD dwNewValue,
    DWORD* pdwOutValue
);
[DllImport("RESUTILS.dll", ExactSpelling = true)]
static extern uint ResUtilSetDwordValue(
    IntPtr hkeyClusterKey,   // HKEY
    [MarshalAs(UnmanagedType.LPWStr)] string pszValueName,   // LPCWSTR
    uint dwNewValue,   // DWORD
    ref uint pdwOutValue   // DWORD* in/out
);
<DllImport("RESUTILS.dll", ExactSpelling:=True)>
Public Shared Function ResUtilSetDwordValue(
    hkeyClusterKey As IntPtr,   ' HKEY
    <MarshalAs(UnmanagedType.LPWStr)> pszValueName As String,   ' LPCWSTR
    dwNewValue As UInteger,   ' DWORD
    ByRef pdwOutValue As UInteger   ' DWORD* in/out
) As UInteger
End Function
' hkeyClusterKey : HKEY
' pszValueName : LPCWSTR
' dwNewValue : DWORD
' pdwOutValue : DWORD* in/out
Declare PtrSafe Function ResUtilSetDwordValue Lib "resutils" ( _
    ByVal hkeyClusterKey As LongPtr, _
    ByVal pszValueName As LongPtr, _
    ByVal dwNewValue As Long, _
    ByRef pdwOutValue As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ResUtilSetDwordValue = ctypes.windll.resutils.ResUtilSetDwordValue
ResUtilSetDwordValue.restype = wintypes.DWORD
ResUtilSetDwordValue.argtypes = [
    wintypes.HANDLE,  # hkeyClusterKey : HKEY
    wintypes.LPCWSTR,  # pszValueName : LPCWSTR
    wintypes.DWORD,  # dwNewValue : DWORD
    ctypes.POINTER(wintypes.DWORD),  # pdwOutValue : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RESUTILS.dll')
ResUtilSetDwordValue = Fiddle::Function.new(
  lib['ResUtilSetDwordValue'],
  [
    Fiddle::TYPE_VOIDP,  # hkeyClusterKey : HKEY
    Fiddle::TYPE_VOIDP,  # pszValueName : LPCWSTR
    -Fiddle::TYPE_INT,  # dwNewValue : DWORD
    Fiddle::TYPE_VOIDP,  # pdwOutValue : DWORD* in/out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "resutils")]
extern "system" {
    fn ResUtilSetDwordValue(
        hkeyClusterKey: *mut core::ffi::c_void,  // HKEY
        pszValueName: *const u16,  // LPCWSTR
        dwNewValue: u32,  // DWORD
        pdwOutValue: *mut u32  // DWORD* in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RESUTILS.dll")]
public static extern uint ResUtilSetDwordValue(IntPtr hkeyClusterKey, [MarshalAs(UnmanagedType.LPWStr)] string pszValueName, uint dwNewValue, ref uint pdwOutValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RESUTILS_ResUtilSetDwordValue' -Namespace Win32 -PassThru
# $api::ResUtilSetDwordValue(hkeyClusterKey, pszValueName, dwNewValue, pdwOutValue)
#uselib "RESUTILS.dll"
#func global ResUtilSetDwordValue "ResUtilSetDwordValue" sptr, sptr, sptr, sptr
; ResUtilSetDwordValue hkeyClusterKey, pszValueName, dwNewValue, varptr(pdwOutValue)   ; 戻り値は stat
; hkeyClusterKey : HKEY -> "sptr"
; pszValueName : LPCWSTR -> "sptr"
; dwNewValue : DWORD -> "sptr"
; pdwOutValue : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "RESUTILS.dll"
#cfunc global ResUtilSetDwordValue "ResUtilSetDwordValue" sptr, wstr, int, var
; res = ResUtilSetDwordValue(hkeyClusterKey, pszValueName, dwNewValue, pdwOutValue)
; hkeyClusterKey : HKEY -> "sptr"
; pszValueName : LPCWSTR -> "wstr"
; dwNewValue : DWORD -> "int"
; pdwOutValue : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD ResUtilSetDwordValue(HKEY hkeyClusterKey, LPCWSTR pszValueName, DWORD dwNewValue, DWORD* pdwOutValue)
#uselib "RESUTILS.dll"
#cfunc global ResUtilSetDwordValue "ResUtilSetDwordValue" intptr, wstr, int, var
; res = ResUtilSetDwordValue(hkeyClusterKey, pszValueName, dwNewValue, pdwOutValue)
; hkeyClusterKey : HKEY -> "intptr"
; pszValueName : LPCWSTR -> "wstr"
; dwNewValue : DWORD -> "int"
; pdwOutValue : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	resutils = windows.NewLazySystemDLL("RESUTILS.dll")
	procResUtilSetDwordValue = resutils.NewProc("ResUtilSetDwordValue")
)

// hkeyClusterKey (HKEY), pszValueName (LPCWSTR), dwNewValue (DWORD), pdwOutValue (DWORD* in/out)
r1, _, err := procResUtilSetDwordValue.Call(
	uintptr(hkeyClusterKey),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszValueName))),
	uintptr(dwNewValue),
	uintptr(pdwOutValue),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function ResUtilSetDwordValue(
  hkeyClusterKey: THandle;   // HKEY
  pszValueName: PWideChar;   // LPCWSTR
  dwNewValue: DWORD;   // DWORD
  pdwOutValue: Pointer   // DWORD* in/out
): DWORD; stdcall;
  external 'RESUTILS.dll' name 'ResUtilSetDwordValue';
result := DllCall("RESUTILS\ResUtilSetDwordValue"
    , "Ptr", hkeyClusterKey   ; HKEY
    , "WStr", pszValueName   ; LPCWSTR
    , "UInt", dwNewValue   ; DWORD
    , "Ptr", pdwOutValue   ; DWORD* in/out
    , "UInt")   ; return: DWORD
●ResUtilSetDwordValue(hkeyClusterKey, pszValueName, dwNewValue, pdwOutValue) = DLL("RESUTILS.dll", "dword ResUtilSetDwordValue(void*, char*, dword, void*)")
# 呼び出し: ResUtilSetDwordValue(hkeyClusterKey, pszValueName, dwNewValue, pdwOutValue)
# hkeyClusterKey : HKEY -> "void*"
# pszValueName : LPCWSTR -> "char*"
# dwNewValue : DWORD -> "dword"
# pdwOutValue : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。