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