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

ResUtilSetQwordValue

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

シグネチャ

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

DWORD ResUtilSetQwordValue(
    HKEY hkeyClusterKey,
    LPCWSTR pszValueName,
    ULONGLONG qwNewValue,
    ULONGLONG* pqwOutValue   // optional
);

パラメーター

名前方向説明
hkeyClusterKeyHKEYinQWORD値を書き込む対象のクラスターレジストリキー。
pszValueNameLPCWSTRin書き込む値の名前を示すワイド文字列。
qwNewValueULONGLONGin書き込む新しいULONGLONG値。
pqwOutValueULONGLONG*inoutoptional書き込んだ値を受け取るULONGLONGポインタ。NULL可。

戻り値の型: DWORD

各言語での呼び出し定義

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

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

ResUtilSetQwordValue = ctypes.windll.resutils.ResUtilSetQwordValue
ResUtilSetQwordValue.restype = wintypes.DWORD
ResUtilSetQwordValue.argtypes = [
    wintypes.HANDLE,  # hkeyClusterKey : HKEY
    wintypes.LPCWSTR,  # pszValueName : LPCWSTR
    ctypes.c_ulonglong,  # qwNewValue : ULONGLONG
    ctypes.POINTER(ctypes.c_ulonglong),  # pqwOutValue : ULONGLONG* optional, in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	resutils = windows.NewLazySystemDLL("RESUTILS.dll")
	procResUtilSetQwordValue = resutils.NewProc("ResUtilSetQwordValue")
)

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

extern "resutils" fn ResUtilSetQwordValue(
    hkeyClusterKey: ?*anyopaque, // HKEY
    pszValueName: [*c]const u16, // LPCWSTR
    qwNewValue: u64, // ULONGLONG
    pqwOutValue: [*c]u64 // ULONGLONG* optional, in/out
) callconv(std.os.windows.WINAPI) u32;
proc ResUtilSetQwordValue(
    hkeyClusterKey: pointer,  # HKEY
    pszValueName: WideCString,  # LPCWSTR
    qwNewValue: uint64,  # ULONGLONG
    pqwOutValue: ptr uint64  # ULONGLONG* optional, in/out
): uint32 {.importc: "ResUtilSetQwordValue", stdcall, dynlib: "RESUTILS.dll".}
pragma(lib, "resutils");
extern(Windows)
uint ResUtilSetQwordValue(
    void* hkeyClusterKey,   // HKEY
    const(wchar)* pszValueName,   // LPCWSTR
    ulong qwNewValue,   // ULONGLONG
    ulong* pqwOutValue   // ULONGLONG* optional, in/out
);
ccall((:ResUtilSetQwordValue, "RESUTILS.dll"), stdcall, UInt32,
      (Ptr{Cvoid}, Cwstring, UInt64, Ptr{UInt64}),
      hkeyClusterKey, pszValueName, qwNewValue, pqwOutValue)
# hkeyClusterKey : HKEY -> Ptr{Cvoid}
# pszValueName : LPCWSTR -> Cwstring
# qwNewValue : ULONGLONG -> UInt64
# pqwOutValue : ULONGLONG* optional, in/out -> Ptr{UInt64}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t ResUtilSetQwordValue(
    void* hkeyClusterKey,
    const uint16_t* pszValueName,
    uint64_t qwNewValue,
    uint64_t* pqwOutValue);
]]
local resutils = ffi.load("resutils")
-- resutils.ResUtilSetQwordValue(hkeyClusterKey, pszValueName, qwNewValue, pqwOutValue)
-- hkeyClusterKey : HKEY
-- pszValueName : LPCWSTR
-- qwNewValue : ULONGLONG
-- pqwOutValue : ULONGLONG* optional, in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('RESUTILS.dll');
const ResUtilSetQwordValue = lib.func('__stdcall', 'ResUtilSetQwordValue', 'uint32_t', ['void *', 'str16', 'uint64_t', 'uint64_t *']);
// ResUtilSetQwordValue(hkeyClusterKey, pszValueName, qwNewValue, pqwOutValue)
// hkeyClusterKey : HKEY -> 'void *'
// pszValueName : LPCWSTR -> 'str16'
// qwNewValue : ULONGLONG -> 'uint64_t'
// pqwOutValue : ULONGLONG* optional, in/out -> 'uint64_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("RESUTILS.dll", {
  ResUtilSetQwordValue: { parameters: ["pointer", "buffer", "u64", "pointer"], result: "u32" },
});
// lib.symbols.ResUtilSetQwordValue(hkeyClusterKey, pszValueName, qwNewValue, pqwOutValue)
// hkeyClusterKey : HKEY -> "pointer"
// pszValueName : LPCWSTR -> "buffer"
// qwNewValue : ULONGLONG -> "u64"
// pqwOutValue : ULONGLONG* optional, in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t ResUtilSetQwordValue(
    void* hkeyClusterKey,
    const uint16_t* pszValueName,
    uint64_t qwNewValue,
    uint64_t* pqwOutValue);
C, "RESUTILS.dll");
// $ffi->ResUtilSetQwordValue(hkeyClusterKey, pszValueName, qwNewValue, pqwOutValue);
// hkeyClusterKey : HKEY
// pszValueName : LPCWSTR
// qwNewValue : ULONGLONG
// pqwOutValue : ULONGLONG* optional, in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Resutils extends StdCallLibrary {
    Resutils INSTANCE = Native.load("resutils", Resutils.class);
    int ResUtilSetQwordValue(
        Pointer hkeyClusterKey,   // HKEY
        WString pszValueName,   // LPCWSTR
        long qwNewValue,   // ULONGLONG
        LongByReference pqwOutValue   // ULONGLONG* optional, in/out
    );
}
@[Link("resutils")]
lib LibRESUTILS
  fun ResUtilSetQwordValue = ResUtilSetQwordValue(
    hkeyClusterKey : Void*,   # HKEY
    pszValueName : UInt16*,   # LPCWSTR
    qwNewValue : UInt64,   # ULONGLONG
    pqwOutValue : UInt64*   # ULONGLONG* optional, in/out
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ResUtilSetQwordValueNative = Uint32 Function(Pointer<Void>, Pointer<Utf16>, Uint64, Pointer<Uint64>);
typedef ResUtilSetQwordValueDart = int Function(Pointer<Void>, Pointer<Utf16>, int, Pointer<Uint64>);
final ResUtilSetQwordValue = DynamicLibrary.open('RESUTILS.dll')
    .lookupFunction<ResUtilSetQwordValueNative, ResUtilSetQwordValueDart>('ResUtilSetQwordValue');
// hkeyClusterKey : HKEY -> Pointer<Void>
// pszValueName : LPCWSTR -> Pointer<Utf16>
// qwNewValue : ULONGLONG -> Uint64
// pqwOutValue : ULONGLONG* optional, in/out -> Pointer<Uint64>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ResUtilSetQwordValue(
  hkeyClusterKey: THandle;   // HKEY
  pszValueName: PWideChar;   // LPCWSTR
  qwNewValue: UInt64;   // ULONGLONG
  pqwOutValue: Pointer   // ULONGLONG* optional, in/out
): DWORD; stdcall;
  external 'RESUTILS.dll' name 'ResUtilSetQwordValue';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ResUtilSetQwordValue"
  c_ResUtilSetQwordValue :: Ptr () -> CWString -> Word64 -> Ptr Word64 -> IO Word32
-- hkeyClusterKey : HKEY -> Ptr ()
-- pszValueName : LPCWSTR -> CWString
-- qwNewValue : ULONGLONG -> Word64
-- pqwOutValue : ULONGLONG* optional, in/out -> Ptr Word64
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let resutilsetqwordvalue =
  foreign "ResUtilSetQwordValue"
    ((ptr void) @-> (ptr uint16_t) @-> uint64_t @-> (ptr uint64_t) @-> returning uint32_t)
(* hkeyClusterKey : HKEY -> (ptr void) *)
(* pszValueName : LPCWSTR -> (ptr uint16_t) *)
(* qwNewValue : ULONGLONG -> uint64_t *)
(* pqwOutValue : ULONGLONG* optional, in/out -> (ptr uint64_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library resutils (t "RESUTILS.dll"))
(cffi:use-foreign-library resutils)

(cffi:defcfun ("ResUtilSetQwordValue" res-util-set-qword-value :convention :stdcall) :uint32
  (hkey-cluster-key :pointer)   ; HKEY
  (psz-value-name (:string :encoding :utf-16le))   ; LPCWSTR
  (qw-new-value :uint64)   ; ULONGLONG
  (pqw-out-value :pointer))   ; ULONGLONG* optional, in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ResUtilSetQwordValue = Win32::API::More->new('RESUTILS',
    'DWORD ResUtilSetQwordValue(HANDLE hkeyClusterKey, LPCWSTR pszValueName, UINT64 qwNewValue, LPVOID pqwOutValue)');
# my $ret = $ResUtilSetQwordValue->Call($hkeyClusterKey, $pszValueName, $qwNewValue, $pqwOutValue);
# hkeyClusterKey : HKEY -> HANDLE
# pszValueName : LPCWSTR -> LPCWSTR
# qwNewValue : ULONGLONG -> UINT64
# pqwOutValue : ULONGLONG* optional, in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。