ホーム › Networking.Clustering › ResUtilSetExpandSzValue
ResUtilSetExpandSzValue
関数クラスタキーに展開可能文字列値を設定する。
シグネチャ
// RESUTILS.dll
#include <windows.h>
DWORD ResUtilSetExpandSzValue(
HKEY hkeyClusterKey,
LPCWSTR pszValueName,
LPCWSTR pszNewValue,
LPWSTR* ppszOutString // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hkeyClusterKey | HKEY | in | REG_EXPAND_SZ値を書き込む対象のクラスターレジストリキー。 |
| pszValueName | LPCWSTR | in | 書き込む値の名前を示すワイド文字列。 |
| pszNewValue | LPCWSTR | in | 書き込む新しい展開可能文字列値のワイド文字列。 |
| ppszOutString | LPWSTR* | inoutoptional | 書き込んだ文字列のコピーを受け取るポインタ。LocalFreeで解放する。NULL可。 |
戻り値の型: DWORD
各言語での呼び出し定義
// RESUTILS.dll
#include <windows.h>
DWORD ResUtilSetExpandSzValue(
HKEY hkeyClusterKey,
LPCWSTR pszValueName,
LPCWSTR pszNewValue,
LPWSTR* ppszOutString // optional
);[DllImport("RESUTILS.dll", ExactSpelling = true)]
static extern uint ResUtilSetExpandSzValue(
IntPtr hkeyClusterKey, // HKEY
[MarshalAs(UnmanagedType.LPWStr)] string pszValueName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pszNewValue, // LPCWSTR
IntPtr ppszOutString // LPWSTR* optional, in/out
);<DllImport("RESUTILS.dll", ExactSpelling:=True)>
Public Shared Function ResUtilSetExpandSzValue(
hkeyClusterKey As IntPtr, ' HKEY
<MarshalAs(UnmanagedType.LPWStr)> pszValueName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pszNewValue As String, ' LPCWSTR
ppszOutString As IntPtr ' LPWSTR* optional, in/out
) As UInteger
End Function' hkeyClusterKey : HKEY
' pszValueName : LPCWSTR
' pszNewValue : LPCWSTR
' ppszOutString : LPWSTR* optional, in/out
Declare PtrSafe Function ResUtilSetExpandSzValue Lib "resutils" ( _
ByVal hkeyClusterKey As LongPtr, _
ByVal pszValueName As LongPtr, _
ByVal pszNewValue As LongPtr, _
ByVal ppszOutString As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ResUtilSetExpandSzValue = ctypes.windll.resutils.ResUtilSetExpandSzValue
ResUtilSetExpandSzValue.restype = wintypes.DWORD
ResUtilSetExpandSzValue.argtypes = [
wintypes.HANDLE, # hkeyClusterKey : HKEY
wintypes.LPCWSTR, # pszValueName : LPCWSTR
wintypes.LPCWSTR, # pszNewValue : LPCWSTR
ctypes.c_void_p, # ppszOutString : LPWSTR* optional, in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RESUTILS.dll')
ResUtilSetExpandSzValue = Fiddle::Function.new(
lib['ResUtilSetExpandSzValue'],
[
Fiddle::TYPE_VOIDP, # hkeyClusterKey : HKEY
Fiddle::TYPE_VOIDP, # pszValueName : LPCWSTR
Fiddle::TYPE_VOIDP, # pszNewValue : LPCWSTR
Fiddle::TYPE_VOIDP, # ppszOutString : LPWSTR* optional, in/out
],
-Fiddle::TYPE_INT)#[link(name = "resutils")]
extern "system" {
fn ResUtilSetExpandSzValue(
hkeyClusterKey: *mut core::ffi::c_void, // HKEY
pszValueName: *const u16, // LPCWSTR
pszNewValue: *const u16, // LPCWSTR
ppszOutString: *mut *mut u16 // LPWSTR* optional, in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RESUTILS.dll")]
public static extern uint ResUtilSetExpandSzValue(IntPtr hkeyClusterKey, [MarshalAs(UnmanagedType.LPWStr)] string pszValueName, [MarshalAs(UnmanagedType.LPWStr)] string pszNewValue, IntPtr ppszOutString);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RESUTILS_ResUtilSetExpandSzValue' -Namespace Win32 -PassThru
# $api::ResUtilSetExpandSzValue(hkeyClusterKey, pszValueName, pszNewValue, ppszOutString)#uselib "RESUTILS.dll"
#func global ResUtilSetExpandSzValue "ResUtilSetExpandSzValue" sptr, sptr, sptr, sptr
; ResUtilSetExpandSzValue hkeyClusterKey, pszValueName, pszNewValue, varptr(ppszOutString) ; 戻り値は stat
; hkeyClusterKey : HKEY -> "sptr"
; pszValueName : LPCWSTR -> "sptr"
; pszNewValue : LPCWSTR -> "sptr"
; ppszOutString : LPWSTR* optional, in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "RESUTILS.dll" #cfunc global ResUtilSetExpandSzValue "ResUtilSetExpandSzValue" sptr, wstr, wstr, var ; res = ResUtilSetExpandSzValue(hkeyClusterKey, pszValueName, pszNewValue, ppszOutString) ; hkeyClusterKey : HKEY -> "sptr" ; pszValueName : LPCWSTR -> "wstr" ; pszNewValue : LPCWSTR -> "wstr" ; ppszOutString : LPWSTR* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RESUTILS.dll" #cfunc global ResUtilSetExpandSzValue "ResUtilSetExpandSzValue" sptr, wstr, wstr, sptr ; res = ResUtilSetExpandSzValue(hkeyClusterKey, pszValueName, pszNewValue, varptr(ppszOutString)) ; hkeyClusterKey : HKEY -> "sptr" ; pszValueName : LPCWSTR -> "wstr" ; pszNewValue : LPCWSTR -> "wstr" ; ppszOutString : LPWSTR* optional, in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD ResUtilSetExpandSzValue(HKEY hkeyClusterKey, LPCWSTR pszValueName, LPCWSTR pszNewValue, LPWSTR* ppszOutString) #uselib "RESUTILS.dll" #cfunc global ResUtilSetExpandSzValue "ResUtilSetExpandSzValue" intptr, wstr, wstr, var ; res = ResUtilSetExpandSzValue(hkeyClusterKey, pszValueName, pszNewValue, ppszOutString) ; hkeyClusterKey : HKEY -> "intptr" ; pszValueName : LPCWSTR -> "wstr" ; pszNewValue : LPCWSTR -> "wstr" ; ppszOutString : LPWSTR* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD ResUtilSetExpandSzValue(HKEY hkeyClusterKey, LPCWSTR pszValueName, LPCWSTR pszNewValue, LPWSTR* ppszOutString) #uselib "RESUTILS.dll" #cfunc global ResUtilSetExpandSzValue "ResUtilSetExpandSzValue" intptr, wstr, wstr, intptr ; res = ResUtilSetExpandSzValue(hkeyClusterKey, pszValueName, pszNewValue, varptr(ppszOutString)) ; hkeyClusterKey : HKEY -> "intptr" ; pszValueName : LPCWSTR -> "wstr" ; pszNewValue : LPCWSTR -> "wstr" ; ppszOutString : LPWSTR* optional, in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
resutils = windows.NewLazySystemDLL("RESUTILS.dll")
procResUtilSetExpandSzValue = resutils.NewProc("ResUtilSetExpandSzValue")
)
// hkeyClusterKey (HKEY), pszValueName (LPCWSTR), pszNewValue (LPCWSTR), ppszOutString (LPWSTR* optional, in/out)
r1, _, err := procResUtilSetExpandSzValue.Call(
uintptr(hkeyClusterKey),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszValueName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszNewValue))),
uintptr(ppszOutString),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction ResUtilSetExpandSzValue(
hkeyClusterKey: THandle; // HKEY
pszValueName: PWideChar; // LPCWSTR
pszNewValue: PWideChar; // LPCWSTR
ppszOutString: PPWideChar // LPWSTR* optional, in/out
): DWORD; stdcall;
external 'RESUTILS.dll' name 'ResUtilSetExpandSzValue';result := DllCall("RESUTILS\ResUtilSetExpandSzValue"
, "Ptr", hkeyClusterKey ; HKEY
, "WStr", pszValueName ; LPCWSTR
, "WStr", pszNewValue ; LPCWSTR
, "Ptr", ppszOutString ; LPWSTR* optional, in/out
, "UInt") ; return: DWORD●ResUtilSetExpandSzValue(hkeyClusterKey, pszValueName, pszNewValue, ppszOutString) = DLL("RESUTILS.dll", "dword ResUtilSetExpandSzValue(void*, char*, char*, void*)")
# 呼び出し: ResUtilSetExpandSzValue(hkeyClusterKey, pszValueName, pszNewValue, ppszOutString)
# hkeyClusterKey : HKEY -> "void*"
# pszValueName : LPCWSTR -> "char*"
# pszNewValue : LPCWSTR -> "char*"
# ppszOutString : LPWSTR* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "resutils" fn ResUtilSetExpandSzValue(
hkeyClusterKey: ?*anyopaque, // HKEY
pszValueName: [*c]const u16, // LPCWSTR
pszNewValue: [*c]const u16, // LPCWSTR
ppszOutString: [*c][*c]u16 // LPWSTR* optional, in/out
) callconv(std.os.windows.WINAPI) u32;proc ResUtilSetExpandSzValue(
hkeyClusterKey: pointer, # HKEY
pszValueName: WideCString, # LPCWSTR
pszNewValue: WideCString, # LPCWSTR
ppszOutString: ptr WideCString # LPWSTR* optional, in/out
): uint32 {.importc: "ResUtilSetExpandSzValue", stdcall, dynlib: "RESUTILS.dll".}pragma(lib, "resutils");
extern(Windows)
uint ResUtilSetExpandSzValue(
void* hkeyClusterKey, // HKEY
const(wchar)* pszValueName, // LPCWSTR
const(wchar)* pszNewValue, // LPCWSTR
wchar** ppszOutString // LPWSTR* optional, in/out
);ccall((:ResUtilSetExpandSzValue, "RESUTILS.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Cwstring, Cwstring, Ptr{Ptr{UInt16}}),
hkeyClusterKey, pszValueName, pszNewValue, ppszOutString)
# hkeyClusterKey : HKEY -> Ptr{Cvoid}
# pszValueName : LPCWSTR -> Cwstring
# pszNewValue : LPCWSTR -> Cwstring
# ppszOutString : LPWSTR* optional, in/out -> Ptr{Ptr{UInt16}}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t ResUtilSetExpandSzValue(
void* hkeyClusterKey,
const uint16_t* pszValueName,
const uint16_t* pszNewValue,
uint16_t** ppszOutString);
]]
local resutils = ffi.load("resutils")
-- resutils.ResUtilSetExpandSzValue(hkeyClusterKey, pszValueName, pszNewValue, ppszOutString)
-- hkeyClusterKey : HKEY
-- pszValueName : LPCWSTR
-- pszNewValue : LPCWSTR
-- ppszOutString : LPWSTR* optional, in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('RESUTILS.dll');
const ResUtilSetExpandSzValue = lib.func('__stdcall', 'ResUtilSetExpandSzValue', 'uint32_t', ['void *', 'str16', 'str16', 'void *']);
// ResUtilSetExpandSzValue(hkeyClusterKey, pszValueName, pszNewValue, ppszOutString)
// hkeyClusterKey : HKEY -> 'void *'
// pszValueName : LPCWSTR -> 'str16'
// pszNewValue : LPCWSTR -> 'str16'
// ppszOutString : LPWSTR* optional, in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RESUTILS.dll", {
ResUtilSetExpandSzValue: { parameters: ["pointer", "buffer", "buffer", "pointer"], result: "u32" },
});
// lib.symbols.ResUtilSetExpandSzValue(hkeyClusterKey, pszValueName, pszNewValue, ppszOutString)
// hkeyClusterKey : HKEY -> "pointer"
// pszValueName : LPCWSTR -> "buffer"
// pszNewValue : LPCWSTR -> "buffer"
// ppszOutString : LPWSTR* optional, in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t ResUtilSetExpandSzValue(
void* hkeyClusterKey,
const uint16_t* pszValueName,
const uint16_t* pszNewValue,
uint16_t** ppszOutString);
C, "RESUTILS.dll");
// $ffi->ResUtilSetExpandSzValue(hkeyClusterKey, pszValueName, pszNewValue, ppszOutString);
// hkeyClusterKey : HKEY
// pszValueName : LPCWSTR
// pszNewValue : LPCWSTR
// ppszOutString : LPWSTR* 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 ResUtilSetExpandSzValue(
Pointer hkeyClusterKey, // HKEY
WString pszValueName, // LPCWSTR
WString pszNewValue, // LPCWSTR
PointerByReference ppszOutString // LPWSTR* optional, in/out
);
}@[Link("resutils")]
lib LibRESUTILS
fun ResUtilSetExpandSzValue = ResUtilSetExpandSzValue(
hkeyClusterKey : Void*, # HKEY
pszValueName : UInt16*, # LPCWSTR
pszNewValue : UInt16*, # LPCWSTR
ppszOutString : UInt16** # LPWSTR* 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 ResUtilSetExpandSzValueNative = Uint32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Pointer<Utf16>>);
typedef ResUtilSetExpandSzValueDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Pointer<Utf16>>);
final ResUtilSetExpandSzValue = DynamicLibrary.open('RESUTILS.dll')
.lookupFunction<ResUtilSetExpandSzValueNative, ResUtilSetExpandSzValueDart>('ResUtilSetExpandSzValue');
// hkeyClusterKey : HKEY -> Pointer<Void>
// pszValueName : LPCWSTR -> Pointer<Utf16>
// pszNewValue : LPCWSTR -> Pointer<Utf16>
// ppszOutString : LPWSTR* optional, in/out -> Pointer<Pointer<Utf16>>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ResUtilSetExpandSzValue(
hkeyClusterKey: THandle; // HKEY
pszValueName: PWideChar; // LPCWSTR
pszNewValue: PWideChar; // LPCWSTR
ppszOutString: PPWideChar // LPWSTR* optional, in/out
): DWORD; stdcall;
external 'RESUTILS.dll' name 'ResUtilSetExpandSzValue';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ResUtilSetExpandSzValue"
c_ResUtilSetExpandSzValue :: Ptr () -> CWString -> CWString -> Ptr CWString -> IO Word32
-- hkeyClusterKey : HKEY -> Ptr ()
-- pszValueName : LPCWSTR -> CWString
-- pszNewValue : LPCWSTR -> CWString
-- ppszOutString : LPWSTR* optional, in/out -> Ptr CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let resutilsetexpandszvalue =
foreign "ResUtilSetExpandSzValue"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr (ptr uint16_t)) @-> returning uint32_t)
(* hkeyClusterKey : HKEY -> (ptr void) *)
(* pszValueName : LPCWSTR -> (ptr uint16_t) *)
(* pszNewValue : LPCWSTR -> (ptr uint16_t) *)
(* ppszOutString : LPWSTR* optional, in/out -> (ptr (ptr uint16_t)) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library resutils (t "RESUTILS.dll"))
(cffi:use-foreign-library resutils)
(cffi:defcfun ("ResUtilSetExpandSzValue" res-util-set-expand-sz-value :convention :stdcall) :uint32
(hkey-cluster-key :pointer) ; HKEY
(psz-value-name (:string :encoding :utf-16le)) ; LPCWSTR
(psz-new-value (:string :encoding :utf-16le)) ; LPCWSTR
(ppsz-out-string :pointer)) ; LPWSTR* optional, in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ResUtilSetExpandSzValue = Win32::API::More->new('RESUTILS',
'DWORD ResUtilSetExpandSzValue(HANDLE hkeyClusterKey, LPCWSTR pszValueName, LPCWSTR pszNewValue, LPVOID ppszOutString)');
# my $ret = $ResUtilSetExpandSzValue->Call($hkeyClusterKey, $pszValueName, $pszNewValue, $ppszOutString);
# hkeyClusterKey : HKEY -> HANDLE
# pszValueName : LPCWSTR -> LPCWSTR
# pszNewValue : LPCWSTR -> LPCWSTR
# ppszOutString : LPWSTR* optional, in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。