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