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